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:
parent
7304ec2135
commit
9b3d987711
2 changed files with 13 additions and 4 deletions
|
|
@ -1225,11 +1225,18 @@ class Client extends EventEmitter {
|
||||||
|
|
||||||
const msgs = await window.Store.PinnedMsgUtils.getTable().equals(['chatId'], chatWid.toString());
|
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
|
return !pinnedMsgs.length
|
||||||
? []
|
? []
|
||||||
: pinnedMsgs.map((msg) => window.WWebJS.getMessageModel(msg));
|
: await Promise.all(pinnedMsgs.map((msg) => window.WWebJS.getMessageModel(msg)));
|
||||||
}, chatId);
|
}, chatId);
|
||||||
|
|
||||||
return pinnedMsgs.map((msg) => new Message(this, msg));
|
return pinnedMsgs.map((msg) => new Message(this, msg));
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,7 @@ exports.ExposeStore = () => {
|
||||||
window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
|
window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
|
||||||
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
||||||
window.Store.AddonPollVoteTable = window.require('WAWebAddonPollVoteTableMode').pollVoteTableMode;
|
window.Store.AddonPollVoteTable = window.require('WAWebAddonPollVoteTableMode').pollVoteTableMode;
|
||||||
window.Store.PinnedMsgUtils = window.require('WAWebPinInChatSchema');
|
|
||||||
window.Store.ChatGetters = window.require('WAWebChatGetters');
|
window.Store.ChatGetters = window.require('WAWebChatGetters');
|
||||||
window.Store.PinnedMsgUtils = window.require('WAWebSendPinMessageAction');
|
|
||||||
window.Store.UploadUtils = window.require('WAWebUploadManager');
|
window.Store.UploadUtils = window.require('WAWebUploadManager');
|
||||||
window.Store.WAWebStreamModel = window.require('WAWebStreamModel');
|
window.Store.WAWebStreamModel = window.require('WAWebStreamModel');
|
||||||
window.Store.FindOrCreateChat = window.require('WAWebFindChatAction');
|
window.Store.FindOrCreateChat = window.require('WAWebFindChatAction');
|
||||||
|
|
@ -118,6 +116,10 @@ exports.ExposeStore = () => {
|
||||||
window.Store.ForwardUtils = {
|
window.Store.ForwardUtils = {
|
||||||
...window.require('WAWebChatForwardMessage')
|
...window.require('WAWebChatForwardMessage')
|
||||||
};
|
};
|
||||||
|
window.Store.PinnedMsgUtils = {
|
||||||
|
...window.require('WAWebPinInChatSchema'),
|
||||||
|
...window.require('WAWebSendPinMessageAction')
|
||||||
|
};
|
||||||
window.Store.ScheduledEventMsgUtils = {
|
window.Store.ScheduledEventMsgUtils = {
|
||||||
...window.require('WAWebGenerateEventCallLink'),
|
...window.require('WAWebGenerateEventCallLink'),
|
||||||
...window.require('WAWebSendEventEditMsgAction'),
|
...window.require('WAWebSendEventEditMsgAction'),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue