This commit is contained in:
Peter Maquiran
2022-02-09 17:06:12 +01:00
parent 3679091e60
commit faa30ee56e
8 changed files with 23 additions and 14 deletions
+12 -4
View File
@@ -67,6 +67,15 @@ export class RoomService {
private NfService: NfService
) {
this.NativeNotificationService.askForPermission()
this.WsChatService.registerCallback({
type: 'reConnect',
funx: ()=>{
this.hasLoadHistory = false
}
})
}
setData({ customFields, id, name, t, lastMessage = new MessageService(this.storage, this.NfService, this.WsChatService), _updatedAt }) {
@@ -181,6 +190,7 @@ export class RoomService {
deleteMessage(id) {
this.messages.forEach((message, index) => {
if(message._id == id) {
alert('found and delete')
this.messages.splice(index, 1)
this.deleteMessageFromDb(id)
@@ -232,8 +242,6 @@ export class RoomService {
file,
temporaryData
}
console.log('offlineChatMessage', offlineChatMessage)
this.addMessageDB(offlineChatMessage)
const message: MessageService = this.prepareMessage(offlineChatMessage)
@@ -355,9 +363,9 @@ export class RoomService {
}
// runs onces only
async loadHistory(limit = 100) {
async loadHistory({limit = 100, forceUpdate = false }) {
if (this.hasLoadHistory) { return false }
if (this.hasLoadHistory || forceUpdate) { return false }
this.restoreMessageFromDB()
@@ -210,7 +210,7 @@ export class WsChatMethodsService {
this.prepareRoom(roomData);
this.getGroupRoom(id).loadHistory();
this.getGroupRoom(id).loadHistory({});
}
+1 -1
View File
@@ -273,7 +273,7 @@ export class WsChatService {
return new Promise ((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message) =>{
if(message.id == requestId || deepFind(message, 'result') == requestId){
if(message.id == requestId ){
resolve(message)
return true
}