teste/route

This commit is contained in:
Peter Maquiran
2022-02-16 15:52:59 +01:00
parent 1efea5bdf7
commit 439332a52e
35 changed files with 309 additions and 286 deletions
@@ -22,8 +22,8 @@ export class WsChatMethodsService {
dm: {[key: string]: RoomService} = {}
group: {[key: string]: RoomService} = {}
_dm = []
_group = []
_dm: RoomService[] = []
_group: RoomService[] = []
loadingWholeList = false
@@ -71,7 +71,9 @@ export class WsChatMethodsService {
}
})
this.changeProfileService.registerCallback(()=>{
// on change profile remove a rooms
this.changeProfileService.registerCallback(() => {
this.clearChat()
this.ReLoadChat()
this.storage.remove('Rooms');
@@ -142,13 +144,6 @@ export class WsChatMethodsService {
this.users = []
}
getRoomFromDb() {
this.storage.get('Rooms').then((rooms) => {
rooms.result.update.forEach((roomData: room) => {
this.prepareRoom(roomData);
});
})
}
openRoom(roomId) {
@@ -186,7 +181,6 @@ export class WsChatMethodsService {
async getAllRooms () {
this.loadingWholeList = true
//this.getRoomFromDb();
const rooms = await this.WsChatService.getRooms();
await this.storage.remove('Rooms');
await this.storage.set('Rooms', rooms);
@@ -266,6 +260,9 @@ export class WsChatMethodsService {
prepareRoom(roomData) {
/**
* @description data used to define or create room
*/
const setData = {
customFields: roomData.customFields,
id: this.getRoomId(roomData),
@@ -277,14 +274,16 @@ export class WsChatMethodsService {
let roomId = this.getRoomId(roomData)
if(!this.dm[roomId] && !this.group[roomId]) {
// create room
if(!this.roomExist(roomId)) {
let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService)
room.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
room.receiveMessageDelete();
room.sortRoomList = this.sortRoomList
// create individual room
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
@@ -292,12 +291,16 @@ export class WsChatMethodsService {
this.dmCount++
} else {
// create group room
this.group[roomId] = room
this._group.push(room)
this.groupCount++
}
} else {
// in this case room is already present, therefor it will only be necessary,
// to redefine
if(this.dm[roomId]) {
this.dm[roomId].setData(setData)
@@ -306,11 +309,11 @@ export class WsChatMethodsService {
}
}
}
roomExist(roomId) {
return this.dm[roomId] && this.group[roomId]
}
getReceptorName(roomData) {
try {
@@ -326,20 +329,20 @@ export class WsChatMethodsService {
*/
private getUserStatus(id?:string) {
// this.WsChatService.getUserStatus((d) => {
this.WsChatService.getUserStatus((d) => {
// const username = d.fields.args[0][1]
// const statusNum = d.fields.args[0][2]
const username = d.fields.args[0][1]
const statusNum = d.fields.args[0][2]
// const statusText = this.statusNumberToText(statusNum)
const statusText = this.statusNumberToText(statusNum)
// const user = this.getUserByName(username)
const user = this.getUserByName(username)
// if(user) {
// user.status = statusText
// }
if(user) {
user.status = statusText
}
// })
})
}
@@ -377,7 +380,11 @@ export class WsChatMethodsService {
}
hidingRoom(id?) {
return this.WsChatService.hidingRoom(id);
return this.WsChatService.hidingRoom(id).then(()=>{
// this.hideRoom(id)
})
}
addRoomOwner(roomid, userId){
@@ -403,7 +410,7 @@ export class WsChatMethodsService {
getRoomName(roomData: room) {
if(this.isIndividual(roomData)) {
const names: String[] = roomData.usernames
const roomName = names.filter((name)=>{
const roomName = names.filter((name, index)=>{
return name != SessionStore.user.RochetChatUser
})[0]