This commit is contained in:
Peter Maquiran
2022-02-08 17:44:15 +01:00
parent cef4c39d6e
commit 6a5a486293
15 changed files with 144 additions and 80 deletions
@@ -13,13 +13,14 @@ import { NativeNotificationService } from 'src/app/services/native-notification.
import { SortService } from '../functions/sort.service';
import { chatUser } from 'src/app/models/chatMethod';
import { NfService } from 'src/app/services/chat/nf.service'
@Injectable({
providedIn: 'root'
})
export class WsChatMethodsService {
dm: {[key: string]: RoomService} = {}
group: {[key: string]: RoomService} = {}
dm = {}
group = {}
_dm = []
@@ -42,9 +43,10 @@ export class WsChatMethodsService {
private NativeNotificationService: NativeNotificationService,
private sortService: SortService,
private ChatService: ChatService,
private NfService: NfService
private NfService: NfService,
) {
(async()=>{
await this.restoreRooms()
await this.getAllRooms();
this.subscribeToRoom()
@@ -98,6 +100,24 @@ export class WsChatMethodsService {
}
async restoreRooms() {
try {
const rooms = await this.storage.get('Rooms');
if(rooms) {
await rooms.result.update.forEach( async (roomData: room) => {
await this.prepareRoom(roomData);
});
}
} catch(e){}
this.sortRoomList()
}
async getAllRooms () {
this.loadingWholeList = true
//this.getRoomFromDb();
@@ -105,6 +125,13 @@ export class WsChatMethodsService {
await this.storage.remove('Rooms');
await this.storage.set('Rooms', rooms);
console.log('rooms', rooms)
this.dm = {}
this.group = {}
this._dm = []
this._group = []
// console.log("ROOMS" + JSON.stringify(rooms))
this.WsChatService.registerCallback({
type:'Onmessage',