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
@@ -109,7 +109,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
};
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked;
this.wsChatMethodsService.openRoom(this.roomId)
+1 -1
View File
@@ -124,7 +124,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
};
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory()
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.wsChatMethodsService.openRoom(this.roomId)
+4 -2
View File
@@ -43,7 +43,6 @@ export class AlertService {
}
async confirmDeleteMessage(msgId:any, room:any) {
console.log(room);
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
@@ -60,7 +59,10 @@ export class AlertService {
text: 'Apagar',
handler: () => {
//const loader = this.toastService.loading();
this.wsChatMethodsService.deleteMessage(msgId);
this.wsChatMethodsService.deleteMessage(msgId).then(()=>{
room.deleteMessage(msgId)
})
//this.wsChatMethodsService.subscribeToRoomUpdate(room._id, room);
//loader.remove();
}
+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)
@@ -233,8 +243,6 @@ export class RoomService {
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
}
@@ -121,7 +121,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.getRoomInfo();
//this.scrollToBottom();
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
// console.log('MESSAGES'+ this.wsChatMethodsService.getGroupRoom(this.roomId).messages);
this.wsChatMethodsService.openRoom(this.roomId)
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
@@ -272,7 +272,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
async getRoomInfo() {
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
this.room = room['room'];
if (this.room.name) {
@@ -110,7 +110,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
ngOnChanges(changes: SimpleChanges): void {
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory()
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
@@ -124,7 +124,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.scrollToBottomClicked()
}, 150)
}
ngOnInit() {