fix merge

This commit is contained in:
Peter Maquiran
2022-01-28 16:26:21 +01:00
23 changed files with 596 additions and 423 deletions
@@ -9,6 +9,7 @@ import { Storage } from '@ionic/storage';
import { Platform } from '@ionic/angular';
import { SqliteService } from 'src/app/services/sqlite.service';
import { NativeNotificationService } from 'src/app/services/native-notification.service';
import { SortService } from '../functions/sort.service';
@Injectable({
providedIn: 'root'
@@ -28,7 +29,8 @@ export class WsChatMethodsService {
private storage: Storage,
private platform: Platform,
private sqlservice: SqliteService,
private NativeNotificationService: NativeNotificationService
private NativeNotificationService: NativeNotificationService,
private sortService: SortService
) {
(async()=>{
await this.getAllRooms();
@@ -46,30 +48,7 @@ export class WsChatMethodsService {
// console.log("ROOMS" + JSON.stringify(rooms))
rooms.result.update.forEach((roomData: room) => {
let room:RoomService;
room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice, this.NativeNotificationService)
room.setData({
customFields: roomData.customFields,
id: this.getRoomId(roomData),
name: this.getRoomName(roomData),
t: roomData.t,
lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date'])
})
room.receiveMessage()
let roomId = this.getRoomId(roomData)
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
this.dmCount++
} else {
this.group[roomId] = room
this.groupCount++
}
this.prepareRoom(roomData);
});
this.loadingWholeList = false
@@ -83,6 +62,9 @@ export class WsChatMethodsService {
})
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
console.log('streamNotifyRoomDeleteMessage', subscription);
})
}
for (const id in this.group) {
@@ -91,13 +73,69 @@ export class WsChatMethodsService {
})
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
console.log('streamNotifyRoomDeleteMessage', subscription);
})
}
this.WsChatService.streamNotifyLogged().then((subscription=>{
console.log('streamRoomMessages', subscription)
}))
}
subscribeToRoomUpdate(id, roomData) {
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
console.log('streamRoomMessages', subscription)
})
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
console.log('streamRoomMessages', subscription)
})
this.WsChatService.streamNotifyLogged().then((subscription=>{
console.log('streamRoomMessages', subscription)
}))
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
console.log('streamNotifyRoomDeleteMessage', subscription);
})
this.prepareRoom(roomData);
this.getGroupRoom(id).loadHistory();
}
prepareRoom(roomData){
let room:RoomService;
room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice, this.NativeNotificationService)
room.setData({
customFields: roomData.customFields,
id: this.getRoomId(roomData),
name: this.getRoomName(roomData),
t: roomData.t,
lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date'])
})
room.receiveMessage()
room.receiveMessageDelete();
let roomId = this.getRoomId(roomData)
if(this.isIndividual(roomData)) {
console.log(room);
this.dm[roomId] = room
this.dmCount++
} else {
this.group[roomId] = room
this.groupCount++
}
}
deleteMessage(id?) {
return this.WsChatService.deleteMessage(id);
}
leaveRoom(id?) {
return this.WsChatService.leaveRoom(id);
}
@@ -110,6 +148,10 @@ export class WsChatMethodsService {
return this.WsChatService.addRoomOwner(roomid, userId);
}
createPrivateRoom(groupName, username, customFields){
return this.WsChatService.createPrivateRoom(groupName, username, customFields);
}
getDmRoom(id): RoomService {
try {
return this.dm[id]
@@ -141,7 +183,7 @@ export class WsChatMethodsService {
return roomData._id
}
getRoomLastMessage(roomData: room) {
getRoomLastMessage(roomData: room):any {
return roomData.lastMessage
}