mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
clear storage and add group
This commit is contained in:
@@ -17,7 +17,7 @@ import { ChangeProfileService } from '../change-profile.service';
|
||||
import { ChatMethodsService } from './chat-methods.service';
|
||||
import { AESEncrypt } from '../aesencrypt.service'
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { NetworkServiceService} from 'src/app/services/network-service.service';
|
||||
import { NetworkServiceService } from 'src/app/services/network-service.service';
|
||||
import { ViewedMessageService } from './viewed-message.service'
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
import { Subscribe } from '../subcribe';
|
||||
@@ -30,8 +30,8 @@ const { App } = Plugins;
|
||||
})
|
||||
export class ChatSystemService {
|
||||
|
||||
dm: {[key: string]: RoomService} = {}
|
||||
group: {[key: string]: RoomService} = {}
|
||||
dm: { [key: string]: RoomService } = {}
|
||||
group: { [key: string]: RoomService } = {}
|
||||
|
||||
_dm: RoomService[] = []
|
||||
_group: RoomService[] = []
|
||||
@@ -47,7 +47,7 @@ export class ChatSystemService {
|
||||
delete = []
|
||||
loadingUsers = false
|
||||
|
||||
onRoomsLoad = new Subscribe({execute : false, deleteOnExecute: true})
|
||||
onRoomsLoad = new Subscribe({ execute: false, deleteOnExecute: true })
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -61,9 +61,9 @@ export class ChatSystemService {
|
||||
private NfService: NfService,
|
||||
private changeProfileService: ChangeProfileService,
|
||||
private chatService: ChatService,
|
||||
private ChatMethodsService:ChatMethodsService,
|
||||
private ChatMethodsService: ChatMethodsService,
|
||||
private AESEncrypt: AESEncrypt,
|
||||
private AttachmentsService:AttachmentsService,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService
|
||||
@@ -72,7 +72,7 @@ export class ChatSystemService {
|
||||
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
type: 'reConnect',
|
||||
funx: async () => {
|
||||
funx: async () => {
|
||||
/**
|
||||
* @description when the phone is in the background for a long time it could disconnects from the socket then the socket reconnects automatically,
|
||||
* when the connection is lost the subscribe is also lost, so we have to subscribe again when reconnection is establish.
|
||||
@@ -87,8 +87,8 @@ export class ChatSystemService {
|
||||
//
|
||||
|
||||
|
||||
if(this.currentRoom) {
|
||||
this.currentRoom.loadHistory({forceUpdate: true})
|
||||
if (this.currentRoom) {
|
||||
this.currentRoom.loadHistory({ forceUpdate: true })
|
||||
}
|
||||
|
||||
for (const id in this.dm) {
|
||||
@@ -102,18 +102,18 @@ export class ChatSystemService {
|
||||
}
|
||||
})
|
||||
|
||||
if(this.sessionStore.user.Inactivity) {
|
||||
if (this.sessionStore.user.Inactivity) {
|
||||
this.loadChat();
|
||||
}
|
||||
|
||||
|
||||
if(SessionStore.user?.ChatData?.data) {
|
||||
if (SessionStore.user?.ChatData?.data) {
|
||||
this.restoreRooms();
|
||||
}
|
||||
|
||||
document.addEventListener('resume', () => {
|
||||
this.RochetChatConnectorService.setStatus('online')
|
||||
if(this._dm?.length == 0 && this._group?.length == 0) {
|
||||
if (this._dm?.length == 0 && this._group?.length == 0) {
|
||||
this.getAllRooms();
|
||||
}
|
||||
});
|
||||
@@ -124,12 +124,12 @@ export class ChatSystemService {
|
||||
// The app is in the foreground.
|
||||
console.log('App is in the foreground');
|
||||
|
||||
this.currentRoom?.loadHistory({forceUpdate: true})
|
||||
this.currentRoom?.loadHistory({ forceUpdate: true })
|
||||
|
||||
setTimeout(() => {
|
||||
this.subscribeToRoom()
|
||||
this.RochetChatConnectorService.setStatus('online')
|
||||
},1000);
|
||||
}, 1000);
|
||||
|
||||
/* this.reloadComponent(true) */
|
||||
} else {
|
||||
@@ -143,7 +143,7 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
loadChat() {
|
||||
if(SessionStore.user?.ChatData?.data) {
|
||||
if (SessionStore.user?.ChatData?.data) {
|
||||
this.ReLoadChat()
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ export class ChatSystemService {
|
||||
this.getUserStatus();
|
||||
await this.chatService.refreshtoken();
|
||||
|
||||
await this.restoreUsers();
|
||||
this.restoreUsers();
|
||||
await this.getUser();
|
||||
await this.restoreRooms();
|
||||
await this.getAllRooms();
|
||||
@@ -181,13 +181,13 @@ export class ChatSystemService {
|
||||
|
||||
openRoom(roomId) {
|
||||
|
||||
if(this.currentRoom) {
|
||||
if (this.currentRoom) {
|
||||
this.currentRoom.roomLeave()
|
||||
}
|
||||
|
||||
if(this.getDmRoom(roomId)) {
|
||||
if (this.getDmRoom(roomId)) {
|
||||
this.currentRoom = this.getDmRoom(roomId)
|
||||
} else if(this.getGroupRoom(roomId)) {
|
||||
} else if (this.getGroupRoom(roomId)) {
|
||||
this.currentRoom = this.getGroupRoom(roomId)
|
||||
}
|
||||
|
||||
@@ -196,9 +196,9 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
getRoomById(roomId) {
|
||||
if(this.getDmRoom(roomId)) {
|
||||
if (this.getDmRoom(roomId)) {
|
||||
return this.getDmRoom(roomId)
|
||||
} else if(this.getGroupRoom(roomId)) {
|
||||
} else if (this.getGroupRoom(roomId)) {
|
||||
return this.getGroupRoom(roomId)
|
||||
}
|
||||
}
|
||||
@@ -208,19 +208,19 @@ export class ChatSystemService {
|
||||
try {
|
||||
const _rooms = await this.storage.get('Rooms');
|
||||
|
||||
if(_rooms) {
|
||||
for (let roomData of this.sortArrayISODate(_rooms)) {
|
||||
if (_rooms) {
|
||||
for (let roomData of this.sortArrayISODate(_rooms)) {
|
||||
await this.prepareRoom(roomData);
|
||||
}
|
||||
}
|
||||
} catch(e){}
|
||||
} catch (e) { }
|
||||
|
||||
}
|
||||
|
||||
async restoreUsers () {
|
||||
async restoreUsers() {
|
||||
const users = await this.storage.get('Users');
|
||||
|
||||
if(users) {
|
||||
if (users) {
|
||||
this.users = users
|
||||
|
||||
}
|
||||
@@ -228,45 +228,45 @@ export class ChatSystemService {
|
||||
|
||||
sortArrayISODate(messages: any): any[] {
|
||||
|
||||
return messages.sort((a,b) =>
|
||||
new Date(b._updatedAt ).getTime()
|
||||
return messages.sort((a, b) =>
|
||||
new Date(b._updatedAt).getTime()
|
||||
-
|
||||
new Date(a._updatedAt).getTime())
|
||||
}
|
||||
|
||||
async getAllRooms (callback:Function = () =>{} , roomIdCallback = "") {
|
||||
async getAllRooms(callback: Function = () => { }, roomIdCallback = "") {
|
||||
this.loadingWholeList = true
|
||||
var rooms;
|
||||
|
||||
if(this.RochetChatConnectorService.isLogin) {
|
||||
if (this.RochetChatConnectorService.isLogin) {
|
||||
try {
|
||||
rooms = await this.RochetChatConnectorService.getRooms();
|
||||
} catch (error) {
|
||||
this.loadingWholeList = false
|
||||
console.error('chatgetrooms',error)
|
||||
console.error('chatgetrooms', error)
|
||||
}
|
||||
try {
|
||||
await this.storage.remove('Rooms');
|
||||
} catch(e) {}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
let index = 0
|
||||
|
||||
let _rooms = rooms?.result?.update
|
||||
|
||||
if(_rooms) {
|
||||
if (_rooms) {
|
||||
|
||||
_rooms = _rooms.map( e => {
|
||||
_rooms = _rooms.map(e => {
|
||||
e["_updatedAt"] = e._updatedAt || e._updatedAt['$date']
|
||||
return e
|
||||
})
|
||||
|
||||
for (let roomData of this.sortArrayISODate(_rooms) ) {
|
||||
for (let roomData of this.sortArrayISODate(_rooms)) {
|
||||
|
||||
|
||||
const roomId = this.getRoomId(roomData);
|
||||
|
||||
if(roomData.t == 'd') {
|
||||
if (roomData.t == 'd') {
|
||||
|
||||
let error = false
|
||||
let res;
|
||||
@@ -278,7 +278,7 @@ export class ChatSystemService {
|
||||
error = true
|
||||
}
|
||||
|
||||
if(error) {
|
||||
if (error) {
|
||||
res = await this.chatService.getMembers(roomId).toPromise();
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ export class ChatSystemService {
|
||||
error = true
|
||||
}
|
||||
|
||||
if(error) {
|
||||
if (error) {
|
||||
res = await this.chatService.getGroupMembers(roomId).toPromise()
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ export class ChatSystemService {
|
||||
error = true
|
||||
}
|
||||
|
||||
if(error) {
|
||||
if (error) {
|
||||
res = await this.chatService.getChannelMembers(roomId).toPromise()
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ export class ChatSystemService {
|
||||
|
||||
}
|
||||
|
||||
if(roomId == roomIdCallback) {
|
||||
if (roomId == roomIdCallback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
@@ -363,8 +363,8 @@ export class ChatSystemService {
|
||||
*/
|
||||
sortRoomList = () => {
|
||||
|
||||
this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
|
||||
this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
|
||||
this._dm = this.sortService.sortDate(this._dm, '_updatedAt').reverse()
|
||||
this._group = this.sortService.sortDate(this._group, '_updatedAt').reverse()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,9 +380,9 @@ export class ChatSystemService {
|
||||
this.defaultSubtribe(id)
|
||||
}
|
||||
|
||||
this.RochetChatConnectorService.streamNotifyLogged().then((subscription => {}))
|
||||
this.RochetChatConnectorService.streamNotifyLogged().then((subscription => { }))
|
||||
|
||||
this.RochetChatConnectorService.subStreamMessageUser().then((subscription => {}))
|
||||
this.RochetChatConnectorService.subStreamMessageUser().then((subscription => { }))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,8 +409,15 @@ export class ChatSystemService {
|
||||
|
||||
const room = this.getRoomById(id);
|
||||
|
||||
if(!room.subscribeAttempt) {
|
||||
room.subscribeAttempt = true;
|
||||
if (!room.subscribeAttempt) {
|
||||
|
||||
try {
|
||||
|
||||
room.subscribeAttempt = true;
|
||||
} catch (error) {
|
||||
console.log("error")
|
||||
}
|
||||
|
||||
|
||||
this.RochetChatConnectorService.streamRoomMessages(id).then((subscription) => {
|
||||
room.status.receive.message = true;
|
||||
@@ -435,8 +442,8 @@ export class ChatSystemService {
|
||||
private fix_updatedAt(message) {
|
||||
if (message.result) {
|
||||
message.result._updatedAt = message.result._updatedAt['$date']
|
||||
} else if(message._updatedAt) {
|
||||
if(message._updatedAt.hasOwnProperty('$date')) {
|
||||
} else if (message._updatedAt) {
|
||||
if (message._updatedAt.hasOwnProperty('$date')) {
|
||||
message._updatedAt = message._updatedAt['$date']
|
||||
}
|
||||
}
|
||||
@@ -462,18 +469,18 @@ export class ChatSystemService {
|
||||
name: this.getRoomName(roomData),
|
||||
t: roomData.t,
|
||||
lastMessage: this.getRoomLastMessage(roomData),
|
||||
_updatedAt: new Date( roomData._updatedAt || roomData._updatedAt['$date']),
|
||||
u : roomData.u || {},
|
||||
_updatedAt: new Date(roomData._updatedAt || roomData._updatedAt['$date']),
|
||||
u: roomData.u || {},
|
||||
members: roomData.members,
|
||||
membersExcludeMe: roomData.membersExcludeMe
|
||||
}
|
||||
|
||||
let roomId = this.getRoomId(roomData);
|
||||
|
||||
if (setData.name != 'Rocket Cat' && setData.name != 'general' ) {
|
||||
if (setData.name != 'Rocket Cat' && setData.name != 'general') {
|
||||
// create room
|
||||
if(!this.roomExist(roomId)) {
|
||||
let room:RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this,this.notificationService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService,this.notificationService)
|
||||
if (!this.roomExist(roomId)) {
|
||||
let room: RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.notificationService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService, this.notificationService)
|
||||
room.setData(setData)
|
||||
room.receiveMessage()
|
||||
room.getAllUsers = this.getUsers
|
||||
@@ -483,7 +490,7 @@ export class ChatSystemService {
|
||||
room.isGroup = !this.isIndividual(roomData)
|
||||
|
||||
// create individual room
|
||||
if(this.isIndividual(roomData)) {
|
||||
if (this.isIndividual(roomData)) {
|
||||
|
||||
this.dm[roomId] = room
|
||||
this._dm.push(room)
|
||||
@@ -503,9 +510,9 @@ export class ChatSystemService {
|
||||
// in this case room is already present, therefor it will only be necessary,
|
||||
// to redefine
|
||||
|
||||
if(this.dm[roomId]) {
|
||||
if (this.dm[roomId]) {
|
||||
this.dm[roomId].setData(setData)
|
||||
} else if(this.group[roomId]) {
|
||||
} else if (this.group[roomId]) {
|
||||
this.group[roomId].setData(setData)
|
||||
}
|
||||
|
||||
@@ -515,11 +522,11 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
|
||||
deleteRoom =(roomId) => {
|
||||
deleteRoom = (roomId) => {
|
||||
|
||||
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) {
|
||||
@@ -527,13 +534,13 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
roomExist(roomId) {
|
||||
return this.dm[roomId]?.id || this.group[roomId]?.id
|
||||
return this.dm[roomId]?.id || this.group[roomId]?.id
|
||||
}
|
||||
|
||||
getReceptorName(roomData) {
|
||||
try {
|
||||
return roomData.usernames.find((e)=> e != SessionStore.user.UserName)
|
||||
} catch(e) {
|
||||
return roomData.usernames.find((e) => e != SessionStore.user.UserName)
|
||||
} catch (e) {
|
||||
return '*'
|
||||
}
|
||||
}
|
||||
@@ -542,7 +549,7 @@ export class ChatSystemService {
|
||||
* @description update user status. this method is called once only
|
||||
* @param id user ID
|
||||
*/
|
||||
private getUserStatus(id?:string) {
|
||||
private getUserStatus(id?: string) {
|
||||
|
||||
this.RochetChatConnectorService.getUserStatus(async (d) => {
|
||||
|
||||
@@ -552,8 +559,8 @@ export class ChatSystemService {
|
||||
|
||||
const statusText = this.statusNumberToText(statusNum)
|
||||
|
||||
for ( const user in this.users) {
|
||||
if(this.users[user]._id == userId) {
|
||||
for (const user in this.users) {
|
||||
if (this.users[user]._id == userId) {
|
||||
this.users[user].status = statusText
|
||||
}
|
||||
}
|
||||
@@ -564,7 +571,7 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
getUserByName(username) {
|
||||
return this.users.find((user)=> user.username == username)
|
||||
return this.users.find((user) => user.username == username)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,16 +580,16 @@ export class ChatSystemService {
|
||||
* @returns
|
||||
*/
|
||||
statusNumberToText(text) {
|
||||
if(text == '0') {
|
||||
if (text == '0') {
|
||||
return "offline"
|
||||
}
|
||||
else if(text == '1') {
|
||||
else if (text == '1') {
|
||||
return "online"
|
||||
}
|
||||
else if(text == '2') {
|
||||
else if (text == '2') {
|
||||
return "away"
|
||||
}
|
||||
else if(text == '3') {
|
||||
else if (text == '3') {
|
||||
return "busy"
|
||||
}
|
||||
}
|
||||
@@ -597,15 +604,15 @@ export class ChatSystemService {
|
||||
}
|
||||
|
||||
async hideRoom(id) {
|
||||
this._dm.forEach((md, index)=>{
|
||||
if(md.id == id) {
|
||||
this._dm.forEach((md, index) => {
|
||||
if (md.id == id) {
|
||||
this._dm.splice(index, 1)
|
||||
delete this.dm[id]
|
||||
}
|
||||
});
|
||||
|
||||
this._group.forEach((group, index)=>{
|
||||
if(group.id == id) {
|
||||
this._group.forEach((group, index) => {
|
||||
if (group.id == id) {
|
||||
this._group.splice(index, 1)
|
||||
delete this.group[id]
|
||||
}
|
||||
@@ -614,7 +621,7 @@ export class ChatSystemService {
|
||||
|
||||
hidingRoom(id?) {
|
||||
|
||||
return this.RochetChatConnectorService.hidingRoom(id).then(()=>{
|
||||
return this.RochetChatConnectorService.hidingRoom(id).then(() => {
|
||||
// this.hideRoom(id)
|
||||
})
|
||||
|
||||
@@ -624,39 +631,39 @@ export class ChatSystemService {
|
||||
return this.RochetChatConnectorService.addRoomOwner(roomid, userId);
|
||||
}
|
||||
|
||||
createPrivateRoom(groupName, username, customFields){
|
||||
createPrivateRoom(groupName, username, customFields) {
|
||||
return this.RochetChatConnectorService.createPrivateRoom(groupName, username, customFields);
|
||||
}
|
||||
|
||||
getDmRoom(id): RoomService {
|
||||
try {
|
||||
return this.dm[id]
|
||||
} catch(e) {}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
getGroupRoom(id): RoomService {
|
||||
try {
|
||||
return this.group[id]
|
||||
} catch(e) {}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
getRoomName(roomData: room): string {
|
||||
if(this.isIndividual(roomData)) {
|
||||
if (this.isIndividual(roomData)) {
|
||||
const names: String[] = roomData.usernames
|
||||
const roomName = names.filter((name, index)=>{
|
||||
const roomName = names.filter((name, index) => {
|
||||
return name != SessionStore.user.UserName
|
||||
})[0]
|
||||
|
||||
if(roomName) {
|
||||
if (roomName) {
|
||||
try {
|
||||
const firstName = capitalizeTxt(roomName.split('.')[0])
|
||||
const lastName = capitalizeTxt(roomName.split('.')[1])
|
||||
const lastName = capitalizeTxt(roomName.split('.')[1])
|
||||
return firstName + ' ' + lastName
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return roomData['membersExcludeMe'][0].name
|
||||
}
|
||||
|
||||
} else if(roomData.name) {
|
||||
} else if (roomData.name) {
|
||||
return roomData.name
|
||||
} else {
|
||||
return 'Sem nome'
|
||||
@@ -668,11 +675,11 @@ export class ChatSystemService {
|
||||
}
|
||||
}
|
||||
|
||||
getRoomId(roomData:room) {
|
||||
getRoomId(roomData: room) {
|
||||
return roomData._id
|
||||
}
|
||||
|
||||
getRoomLastMessage(roomData: room):any {
|
||||
getRoomLastMessage(roomData: room): any {
|
||||
return roomData.lastMessage
|
||||
}
|
||||
|
||||
@@ -698,14 +705,14 @@ export class ChatSystemService {
|
||||
|
||||
let users: chatUser[] = _res['users'].filter(data => data.username != SessionStore.user.UserName);
|
||||
|
||||
users = users.filter((data) => !(data.name == 'Rocket.Cat' || data.name == 'Administrator'))
|
||||
users = users.filter((data) => !(data.name == 'Rocket.Cat' || data.name == 'Administrator'))
|
||||
|
||||
const userIds = this.users.map((user) => user._id)
|
||||
|
||||
for(let UserUpdate of users) {
|
||||
if(userIds.includes(UserUpdate._id)) {
|
||||
for (let UserUpdate of users) {
|
||||
if (userIds.includes(UserUpdate._id)) {
|
||||
for (var index = 0; index < this.users.length; index++) {
|
||||
if(UserUpdate._id == this.users[index]._id) {
|
||||
if (UserUpdate._id == this.users[index]._id) {
|
||||
this.users[index] = UserUpdate
|
||||
}
|
||||
}
|
||||
@@ -714,11 +721,11 @@ export class ChatSystemService {
|
||||
}
|
||||
}
|
||||
|
||||
this.users = this.users.sort((a,b) => {
|
||||
if(a.name < b.name) {
|
||||
this.users = this.users.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if(a.name > b.name) {
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -730,7 +737,7 @@ export class ChatSystemService {
|
||||
|
||||
}
|
||||
|
||||
getUserOfRoom(roomId){
|
||||
getUserOfRoom(roomId) {
|
||||
return this.RochetChatConnectorService.getUserOfRoom(roomId);
|
||||
}
|
||||
|
||||
@@ -738,10 +745,10 @@ export class ChatSystemService {
|
||||
async createGroup(name) {
|
||||
const res: any = await this.createPrivateRoom(name, SessionStore.user.UserName, {});
|
||||
console.log('room is created', res)
|
||||
if(res?.result?.rid) {
|
||||
if (res?.result?.rid) {
|
||||
try {
|
||||
await this.getAllRooms();
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
console.log('room is loaded')
|
||||
return res
|
||||
} else {
|
||||
@@ -753,11 +760,11 @@ export class ChatSystemService {
|
||||
async createGroup__(name, customFields = {}) {
|
||||
const res: any = await this.createPrivateRoom(name, SessionStore.user.UserName, customFields);
|
||||
console.log('room is created', res)
|
||||
if(res?.result?.rid) {
|
||||
if (res?.result?.rid) {
|
||||
try {
|
||||
await this.getAllRooms();
|
||||
return res
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
console.log('room is loaded')
|
||||
return res
|
||||
} else {
|
||||
@@ -765,8 +772,8 @@ export class ChatSystemService {
|
||||
}
|
||||
}
|
||||
|
||||
getGroupByName(name ) {
|
||||
return this._group.find( e=> e.name == name)
|
||||
getGroupByName(name) {
|
||||
return this._group.find(e => e.name == name)
|
||||
}
|
||||
|
||||
async waitRoomToCreate(rid): Promise<RoomService> {
|
||||
@@ -783,13 +790,13 @@ export class ChatSystemService {
|
||||
|
||||
try {
|
||||
await this.getAllRooms();
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
searchContact(name, username) {
|
||||
return this.users.find( e=> e.name == name || e.username == username)
|
||||
return this.users.find(e => e.name == name || e.username == username)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user