Merge branch 'frontend_test_general' into 'master'
Frontend test general See merge request groupe100idee/chatless!5
This commit is contained in:
commit
e06c332bd1
3 changed files with 27 additions and 12 deletions
|
|
@ -60,7 +60,7 @@ io.on('connection',socket => {
|
||||||
|
|
||||||
socket.on('general',function(data){
|
socket.on('general',function(data){
|
||||||
const username = data.username;
|
const username = data.username;
|
||||||
const date = Date.now();
|
const date = data.date;
|
||||||
const channel = 'general';
|
const channel = 'general';
|
||||||
const message = data.message;
|
const message = data.message;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ export interface ChatInfo {
|
||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
|
|
@ -39,16 +38,27 @@ export class ChatService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(username: string | null, room: string, message: string) {
|
sendMessage(sender: string | null, receiver: string | null, room: string, message: string) {
|
||||||
|
if(receiver === null){
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.socket.emit(room, {
|
this.socket.emit(room, {
|
||||||
username: username,
|
username: sender,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
room: room,
|
room: room,
|
||||||
message: message
|
message: message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
// @ts-ignore
|
||||||
|
this.socket.emit('privateroom', {
|
||||||
|
sender: sender,
|
||||||
|
receiver: receiver,
|
||||||
|
date: new Date(),
|
||||||
|
message: message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
leaveRoom(): void {
|
leaveRoom(): void {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.socket?.disconnect();
|
this.socket?.disconnect();
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,11 @@ body {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
font-size: 14px;
|
font-size: 20px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
margin-left: 5px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
@ -109,3 +110,7 @@ body {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-footer{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
|
||||||
Reference in a new issue