diff --git a/packages/js-sdk/src/message/Messages.ts b/packages/js-sdk/src/message/Messages.ts index 14cd332e1..b10e642cc 100644 --- a/packages/js-sdk/src/message/Messages.ts +++ b/packages/js-sdk/src/message/Messages.ts @@ -45,17 +45,24 @@ export class Messages { this.hydrateFn = conversations.hydrateExistingContactAsync; } - get meta() { - return { - sender: this.senderAccount, - receiver: this.receiver, - messages: this._messages, - } + get list() { + return renderMessage(this._messages); } - public get list() { - return renderMessage(this._messages); + public async init() { + const messagesContainer = await this.storageApi.getMessages(this.receiver.account.ensName, 10, 0); + + const storedMessages = messagesContainer.map((message) => + ({ + ...message, + reactions: [], + source: MessageSource.Storage, + } as MessageModel), + ); + + this._messages.push(...storedMessages); } + public async sendMessage(msg: string) { const messageWithoutSig: Omit = { message: msg,