Browse Source

made the message page counter to only increment if the current requested page was not empty

master
nova 4 years ago
parent
commit
ddc7f15498
  1. 17
      chatto/src/main/javascript/ts/src/model/ChatModel.ts

17
chatto/src/main/javascript/ts/src/model/ChatModel.ts

@ -67,13 +67,13 @@ export class ChatModel implements Subject {
}
public async getMessages(contactName: string, passphrase: string, lastMessageTime: string | null): Promise<ChatMessageViewModel[]> {
if(this._messagePageMap.get(contactName) == null)
if (this._messagePageMap.get(contactName) == null)
this._messagePageMap.set(contactName, 0);
else {
log.debug('page number before = ' + this._messagePageMap.get(contactName)!)
this._messagePageMap.set(contactName, this._messagePageMap.get(contactName)! + 1);
log.debug('page number after = ' + this._messagePageMap.get(contactName)!)
}
// else {
// log.debug('page number before = ' + this._messagePageMap.get(contactName)!)
// this._messagePageMap.set(contactName, this._messagePageMap.get(contactName)! + 1);
// log.debug('page number after = ' + this._messagePageMap.get(contactName)!)
// }
const pageNumber = this._messagePageMap.get(contactName)
const cVMs = await ChatModelHelper.getMessages(contactName, passphrase, pageNumber!, lastMessageTime, this);
if (cVMs != null) {
@ -101,6 +101,11 @@ export class ChatModel implements Subject {
else {
log.error('Messages were null');
}
if (cVMs.length != 0) {
// log.debug('page number before = ' + this._messagePageMap.get(contactName)!)
this._messagePageMap.set(contactName, this._messagePageMap.get(contactName)! + 1);
// log.debug('page number after = ' + this._messagePageMap.get(contactName)!)
}
return cVMs;
}
Loading…
Cancel
Save