mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user