|
|
@ -67,18 +67,18 @@ 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)!) |
|
|
|
} |
|
|
|
const pageNumber = 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) { |
|
|
|
log.info('Subject: My state has just changed') |
|
|
|
|
|
|
|
|
|
|
|
// this._messagesMap.set(userName, cVMs);
|
|
|
|
const existingMessages = this.getStoredUserMessages(contactName); |
|
|
|
log.debug(existingMessages); |
|
|
@ -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; |
|
|
|
} |