added realtime to: - edit group name

- adicionar membro
- remover membro
This commit is contained in:
tiago.kayaya
2022-01-17 11:27:25 +01:00
parent 3dea6295ae
commit 936351b7ec
9 changed files with 51 additions and 34 deletions
+1
View File
@@ -71,6 +71,7 @@ export interface Message {
msg: string;
ts: Ts;
u: U;
t: string;
_updatedAt: UpdatedAt;
mentions: any[];
channels: any[];
-4
View File
@@ -25,9 +25,6 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src="assets/images/icons-chat-new-group.svg" ></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src="assets/images/theme/gov/icons-chat-new-group.svg" ></ion-icon>
</button>
<button *ngIf="hideRefreshBtn" class="btn-no-color" (click)="refreshing()">
<ion-icon class="title-icon font-awesome" name="reload-circle"></ion-icon>
</button>
</div>
</div>
<ion-toolbar>
@@ -178,7 +175,6 @@
(showEmptyContainer)="showEmptyContainer()"
(showEmptyContainer)="showEmptyContainer()"
(openNewEventPage)="openNewEventPage($event)"
(getDirectMessages)="getDirectMessages($event)"
[style.display]="showMessages ? 'flex' : 'none'"
[roomId]="roomId"
[showMessages]="showMessages" #messagecontainer>
+3 -4
View File
@@ -143,6 +143,9 @@ export class ChatPage implements OnInit {
ngOnInit() {
console.log(this.wsChatMethodsService.group);
this.segment = "Contactos";
this.authService.userData$.subscribe((res: any) => {
@@ -366,10 +369,6 @@ export class ChatPage implements OnInit {
}, 1000);
}
refreshing() {
//this.load();
}
customRoom() {
let params = new HttpParams();
params = params.set("types", "c");
@@ -57,7 +57,7 @@
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -98,7 +98,7 @@
</div>
</div>
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.alias =='documento'" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.alias =='documento'" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -113,7 +113,6 @@
<div>
<div>
<div class="file">
<!-- <canvas id="pdf_canvas"></canvas> -->
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
<span *ngIf="msg.file.type">
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
@@ -160,6 +159,14 @@
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'au'" class="info-text-leave">
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>Adicionou {{user.name}}</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.file">
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
+17 -17
View File
@@ -112,30 +112,30 @@ export class AuthService {
"password": user.password,
}
setTimeout(()=>{
console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password)
this.WsChatService.connect();
this.WsChatService.login().then((message) => {
console.log('rocket chat login successfully', message)
this.WsChatService.setStatus('online')
}).catch((message)=>{
console.log('rocket chat login failed', message)
})
}, 1)
let responseChat = await this.httpService.post('login', postData).toPromise();
if(responseChat) {
setTimeout(()=>{
console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password)
this.WsChatService.connect();
this.WsChatService.login().then((message) => {
console.log('rocket chat login successfully', message)
this.WsChatService.setStatus('online')
}).catch((message)=>{
console.log('rocket chat login failed', message)
})
}, 1)
console.log('Login to Rocket chat OK');
this.ValidatedUserChat = responseChat;
localStorage.setItem('userChat', JSON.stringify(responseChat));
localStorage.setItem('Meteor.loginToken', responseChat['data'].authToken);
localStorage.setItem('Meteor.userId',responseChat['data'].userId);
this.cookieService.set('rc_token', responseChat['data'].authToken);
this.cookieService.set('rc_uid', responseChat['data'].userId);
this.storageService.store(AuthConnstants.AUTH, responseChat);
return true;
}
else{
+3 -1
View File
@@ -14,6 +14,7 @@ export class MessageService {
rid = ''
ts = {}
u = {}
t = ''
_id =''
_updatedAt = {}
file
@@ -21,7 +22,7 @@ export class MessageService {
constructor() { }
setData({customFields, channels, mentions, msg ,rid ,ts, u, _id, _updatedAt, file, attachments}:Message) {
setData({customFields, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments}:Message) {
this.customFields = customFields
this.channels = channels
this.mentions = mentions
@@ -29,6 +30,7 @@ export class MessageService {
this.rid = rid
this.ts = ts
this.u = u
this.t = t
this._id = _id
this._updatedAt = _updatedAt
this.file = file
+5 -2
View File
@@ -16,6 +16,7 @@ export class RoomService {
chatUser: ChatUserService[] = []
customFields:any;
id = ''
t = ''
name = ''
_updatedAt = {}
private hasLoadHistory = false
@@ -30,10 +31,11 @@ export class RoomService {
private MessageService: MessageService,
) {}
setData({customFields, id, name, lastMessage, _updatedAt}) {
setData({customFields, id, name, t, lastMessage, _updatedAt}) {
this.customFields = customFields
this.id = id
this.name = name
this.t = t
this.lastMessage = lastMessage
this._updatedAt = _updatedAt
@@ -52,13 +54,14 @@ export class RoomService {
const message = new MessageService()
message.setData(ChatMessage)
this.lastMessage.msg = message.msg
if(message.t == 'r'){this.name = message.msg}
this.calDateDuration(ChatMessage._updatedAt)
this.massages.push(message)
setTimeout(()=>{
this.scrollDown()
}, 100)
}
)
}
@@ -27,7 +27,7 @@ export class WsChatMethodsService {
(async()=>{
await this.getAllRooms();
this.subscribeToRoom()
})()
}
@@ -50,6 +50,7 @@ export class WsChatMethodsService {
customFields: roomData.customFields,
id: this.getRoomId(roomData),
name: this.getRoomName(roomData),
t: roomData.t,
lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date'])
})
@@ -45,7 +45,7 @@
</div>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last">
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.msg !=''" >
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" >
<div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
<mat-menu #beforeMenu="matMenu" xPosition="before">
@@ -93,7 +93,7 @@
</div>
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.alias =='documento'" >
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.alias =='documento'" >
<div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
<mat-menu #beforeMenu="matMenu" xPosition="before">
@@ -162,6 +162,14 @@
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'au'" class="info-text-leave">
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>Adicionou {{user.name}}</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.file" >
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />