made the message page counter to only increment if the current requested page was not empty
This commit is contained in:
parent
d927f3441a
commit
ddc7f15498
@ -67,18 +67,18 @@ export class ChatModel implements Subject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getMessages(contactName: string, passphrase: string, lastMessageTime: string | null): Promise<ChatMessageViewModel[]> {
|
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);
|
this._messagePageMap.set(contactName, 0);
|
||||||
else {
|
// else {
|
||||||
log.debug('page number before = ' + this._messagePageMap.get(contactName)!)
|
// log.debug('page number before = ' + this._messagePageMap.get(contactName)!)
|
||||||
this._messagePageMap.set(contactName, this._messagePageMap.get(contactName)! + 1);
|
// this._messagePageMap.set(contactName, this._messagePageMap.get(contactName)! + 1);
|
||||||
log.debug('page number after = ' + this._messagePageMap.get(contactName)!)
|
// log.debug('page number after = ' + this._messagePageMap.get(contactName)!)
|
||||||
}
|
// }
|
||||||
const pageNumber = this._messagePageMap.get(contactName)
|
const pageNumber = this._messagePageMap.get(contactName)
|
||||||
const cVMs = await ChatModelHelper.getMessages(contactName, passphrase, pageNumber!, lastMessageTime, this);
|
const cVMs = await ChatModelHelper.getMessages(contactName, passphrase, pageNumber!, lastMessageTime, this);
|
||||||
if (cVMs != null) {
|
if (cVMs != null) {
|
||||||
log.info('Subject: My state has just changed')
|
log.info('Subject: My state has just changed')
|
||||||
|
|
||||||
// this._messagesMap.set(userName, cVMs);
|
// this._messagesMap.set(userName, cVMs);
|
||||||
const existingMessages = this.getStoredUserMessages(contactName);
|
const existingMessages = this.getStoredUserMessages(contactName);
|
||||||
log.debug(existingMessages);
|
log.debug(existingMessages);
|
||||||
@ -101,6 +101,11 @@ export class ChatModel implements Subject {
|
|||||||
else {
|
else {
|
||||||
log.error('Messages were null');
|
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;
|
return cVMs;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user