fix: Message.pin and Message.unpin (#3319)
* fix: update function to wweb version >2.3000.0 * feat: add foolproof check * fix: override internal function correctly
This commit is contained in:
parent
18b1d32825
commit
ab321f3d7e
2 changed files with 11 additions and 2 deletions
|
|
@ -1100,7 +1100,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.require('WAWebPinMsgConstants').getPinExpiryDuration;
|
||||
window.require('WAWebPinMsgConstants').getPinExpiryDuration = () => duration;
|
||||
|
||||
const response = await window.Store.PinnedMsgUtils.sendPinInChatMsg(message, action, duration);
|
||||
|
||||
window.require('WAWebPinMsgConstants').getPinExpiryDuration = originalFunction;
|
||||
|
||||
return response.messageSendResult === 'OK';
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue