Skip to content

Commit

Permalink
init messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl committed Nov 27, 2024
1 parent b820c01 commit c34edd3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/js-sdk/src/message/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, 'signature'> = {
message: msg,
Expand Down

0 comments on commit c34edd3

Please sign in to comment.