fix: getPinnedMessages() (#3797)

* fix duplicate store

* fix: handle async calls properly

* fix: filter out only pinned messages

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
This commit is contained in:
RendyCraft047 2025-10-08 02:11:37 +07:00 • committed by GitHub
commit 9b3d987711
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View file

@ -1225,11 +1225,18 @@ class Client extends EventEmitter {
const msgs = await window.Store.PinnedMsgUtils.getTable().equals(['chatId'], chatWid.toString());
const pinnedMsgs = msgs.map((msg) => window.Store.Msg.get(msg.parentMsgKey));
const pinnedMsgs = (
await Promise.all(
msgs.filter(msg => msg.pinType == 1).map(async (msg) => {
const res = await window.Store.Msg.getMessagesById([msg.parentMsgKey]);
return res?.messages?.[0];
})
)
).filter(Boolean);
return !pinnedMsgs.length
? []
: pinnedMsgs.map((msg) => window.WWebJS.getMessageModel(msg));
: await Promise.all(pinnedMsgs.map((msg) => window.WWebJS.getMessageModel(msg)));
}, chatId);
return pinnedMsgs.map((msg) => new Message(this, msg));