diff --git a/src/Client.js b/src/Client.js index 8f02a78..4ae134e 100644 --- a/src/Client.js +++ b/src/Client.js @@ -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)); diff --git a/src/util/Injected/Store.js b/src/util/Injected/Store.js index ceb5941..73217b5 100644 --- a/src/util/Injected/Store.js +++ b/src/util/Injected/Store.js @@ -97,9 +97,7 @@ exports.ExposeStore = () => { window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest'); window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode; window.Store.AddonPollVoteTable = window.require('WAWebAddonPollVoteTableMode').pollVoteTableMode; - window.Store.PinnedMsgUtils = window.require('WAWebPinInChatSchema'); window.Store.ChatGetters = window.require('WAWebChatGetters'); - window.Store.PinnedMsgUtils = window.require('WAWebSendPinMessageAction'); window.Store.UploadUtils = window.require('WAWebUploadManager'); window.Store.WAWebStreamModel = window.require('WAWebStreamModel'); window.Store.FindOrCreateChat = window.require('WAWebFindChatAction'); @@ -118,6 +116,10 @@ exports.ExposeStore = () => { window.Store.ForwardUtils = { ...window.require('WAWebChatForwardMessage') }; + window.Store.PinnedMsgUtils = { + ...window.require('WAWebPinInChatSchema'), + ...window.require('WAWebSendPinMessageAction') + }; window.Store.ScheduledEventMsgUtils = { ...window.require('WAWebGenerateEventCallLink'), ...window.require('WAWebSendEventEditMsgAction'),