diff --git a/src/util/Injected/Store.js b/src/util/Injected/Store.js index 2da5871d9f..8f8853fd63 100644 --- a/src/util/Injected/Store.js +++ b/src/util/Injected/Store.js @@ -91,7 +91,6 @@ exports.ExposeStore = () => { window.Store.WidToJid = window.require('WAWebWidToJid'); window.Store.JidToWid = window.require('WAWebJidToWid'); window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo; - window.Store.pinUnpinMsg = window.require('WAWebSendPinMessageAction').sendPinInChatMsg; window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists; window.Store.ReplyUtils = window.require('WAWebMsgReply'); window.Store.Settings = window.require('WAWebUserPrefsGeneral'); @@ -105,7 +104,10 @@ exports.ExposeStore = () => { window.Store.ForwardUtils = { ...window.require('WAWebForwardMessagesToChat') }; - + window.Store.PinnedMsgUtils = { + ...window.require('WAWebSendPinMessageAction'), + ...window.require('WAWebPinMsgConstants') + }; window.Store.StickerTools = { ...window.require('WAWebImageUtils'), ...window.require('WAWebAddWebpMetadata') diff --git a/src/util/Injected/Utils.js b/src/util/Injected/Utils.js index 6052627fde..60e22fe837 100644 --- a/src/util/Injected/Utils.js +++ b/src/util/Injected/Utils.js @@ -1010,7 +1010,16 @@ exports.LoadUtils = () => { window.WWebJS.pinUnpinMsgAction = async (msgId, action, duration) => { const message = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0]; if (!message) return false; - const response = await window.Store.pinUnpinMsg(message, action, duration); + + if (typeof duration !== 'number') return false; + + const originalFunction = window.Store.PinnedMsgUtils.getPinExpiryDuration; + window.Store.PinnedMsgUtils.getPinExpiryDuration = () => duration; + + const response = await window.Store.PinnedMsgUtils.sendPinInChatMsg(message, action, duration); + + window.Store.PinnedMsgUtils.getPinExpiryDuration = originalFunction; + return response.messageSendResult === 'OK'; };