This commit is contained in:
Peter Maquiran
2023-09-19 10:21:23 +01:00
parent 527cc0f2a6
commit f51bd246fc
29 changed files with 754 additions and 261 deletions
+26 -25
View File
@@ -45,7 +45,7 @@ export class ChatSystemService {
onRoomsLoad = new Subscribe({execute : false, deleteOnExecute: true})
constructor(
private RochetChatConnectorService: RochetChatConnectorService,
private storage: Storage,
@@ -76,6 +76,7 @@ export class ChatSystemService {
await this.chatService.refreshtoken();
await this.getUser();
this.RochetChatConnectorService.setStatus('online')
await this.getAllRooms();
this.subscribeToRoom();
//
@@ -179,7 +180,7 @@ export class ChatSystemService {
const rooms = await this.storage.get('Rooms');
if(rooms) {
for (let roomData of rooms.result.update) {
for (let roomData of rooms.result.update) {
await this.prepareRoom(roomData);
}
}
@@ -213,7 +214,7 @@ export class ChatSystemService {
}
try {
await this.storage.remove('Rooms');
} catch(e) {}
} catch(e) {}
}
let index = 0
@@ -224,7 +225,7 @@ export class ChatSystemService {
const roomId = this.getRoomId(roomData);
if(roomData.t == 'd') {
let error = false
let res;
@@ -238,13 +239,13 @@ export class ChatSystemService {
if(error) {
res = await this.chatService.getMembers(roomId).toPromise();
}
const members = res['members'];
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
rooms.result.update[index]['members'] = members
rooms.result.update[index]['membersExcludeMe'] = users
await this.prepareRoom(roomData);
} else {
if (roomData.t === 'p') {
@@ -257,19 +258,19 @@ export class ChatSystemService {
await this.chatService.refreshtoken();
error = true
}
if(error) {
res = await this.chatService.getGroupMembers(roomId).toPromise()
}
const members = res['members'];
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
rooms.result.update[index]['members'] = members
rooms.result.update[index]['membersExcludeMe'] = users
await this.prepareRoom(roomData);
}
else {
@@ -283,7 +284,7 @@ export class ChatSystemService {
await this.chatService.refreshtoken();
error = true
}
if(error) {
res = await this.chatService.getChannelMembers(roomId).toPromise()
}
@@ -291,19 +292,19 @@ export class ChatSystemService {
const members = res['members'];
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
rooms.result.update[index]['members'] = members
rooms.result.update[index]['membersExcludeMe'] = users
await this.prepareRoom(roomData);
}
}
if(roomId == roomIdCallback) {
callback()
}
index++;
}
}
@@ -372,29 +373,29 @@ export class ChatSystemService {
* @param id room id
*/
private defaultSubtribe(id: any) {
const room = this.getRoomById(id);
if(!room.subscribeAttempt) {
room.subscribeAttempt = true;
this.RochetChatConnectorService.streamRoomMessages(id).then((subscription) => {
room.status.receive.message = true;
})
this.RochetChatConnectorService.subStreamNotifyRoom(id, 'typing', false).then((subscription) => {
room.status.receive.typing = true;
//
})
this.RochetChatConnectorService.subStreamNotifyRoom(id, 'readMessage', false).then((subscription) => {
room.status.receive.readMessage = true;
})
this.RochetChatConnectorService.streamNotifyRoomDeleteMessage(id).then((subscription) => {
room.status.receive.deleteMessage = true;
})
}
}
}
@@ -485,7 +486,7 @@ export class ChatSystemService {
this.delete.push(roomId)
delete this.group[roomId];
this._group = this._group.filter((e)=> e.id != roomId);
this._group = this._group.filter((e)=> e.id != roomId);
}
deleteRecently(roomId) {
@@ -626,7 +627,7 @@ export class ChatSystemService {
return 'Sem nome'
}
} else {
return roomData.fname
}