MCPcopy Create free account
hub / github.com/async-labs/async / addMessageToLocalCacheStoreMethod

Method addMessageToLocalCacheStoreMethod

app/lib/store/Chat.ts:187–211  ·  view source on GitHub ↗
(data, parentMessageId)

Source from the content-addressed store, hash-verified

185 }
186
187 public addMessageToLocalCacheStoreMethod(data, parentMessageId) {
188 const messageObj = new Message({ chat: this, store: this.store, ...data });
189
190 if (parentMessageId) {
191 const parentMessage = this.messages.find((m) => m.messageId === parentMessageId);
192
193 parentMessage.messagesInsideThread.push(messageObj);
194 parentMessage.countOfThreadMessages = parentMessage.countOfThreadMessages + 1;
195 } else {
196 this.messages.push(messageObj);
197 this.numberOfMessagesPerChat = this.numberOfMessagesPerChat + 1;
198 }
199
200 if (
201 this.store.currentUser._id === messageObj.createdUserId &&
202 !this.store.currentUser.unreadBySomeoneMessageIds.includes(messageObj.messageId) &&
203 this.chatParticipantIds.length > 1
204 ) {
205 runInAction(() => {
206 this.store.currentUser.unreadBySomeoneMessageIds.push(messageObj.messageId);
207 });
208 }
209
210 return messageObj;
211 }
212
213 public editMessageFromLocalCacheStoreMethod(data) {
214 const message = this.messages.find((m) => m.messageId === data._id);

Calls

no outgoing calls

Tested by

no test coverage detected