diff --git a/src/util/Injected/Store.js b/src/util/Injected/Store.js index 848b08f..2f53421 100644 --- a/src/util/Injected/Store.js +++ b/src/util/Injected/Store.js @@ -102,6 +102,7 @@ exports.ExposeStore = () => { window.Store.PinnedMsgUtils = window.require('WAWebSendPinMessageAction'); window.Store.UploadUtils = window.require('WAWebUploadManager'); window.Store.WAWebStreamModel = window.require('WAWebStreamModel'); + window.Store.FindOrCreateChat = window.require('WAWebFindChatAction'); window.Store.Settings = { ...window.require('WAWebUserPrefsGeneral'), @@ -210,14 +211,21 @@ exports.ExposeStore = () => { * @param {Function} callback Modified function */ window.injectToFunction = (target, callback) => { - const module = window.require(target.module); - const originalFunction = module[target.function]; - const modifiedFunction = (...args) => callback(originalFunction, ...args); - module[target.function] = modifiedFunction; + let module = window.require(target.module); + + const path = target.function.split('.'); + const funcName = path.pop(); + for (const key of path) { + module = module[key]; + } + + const originalFunction = module[funcName]; + module[funcName] = (...args) => callback(originalFunction, ...args); }; window.injectToFunction({ module: 'WAWebBackendJobsCommon', function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); }); window.injectToFunction({ module: 'WAWebE2EProtoUtils', function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); }); + window.injectToFunction({ module: 'WAWebLid1X1MigrationGating', function: 'Lid1X1MigrationUtils.isLidMigrated' }, () => false); }; diff --git a/src/util/Injected/Utils.js b/src/util/Injected/Utils.js index 4b80da9..9281b1a 100644 --- a/src/util/Injected/Utils.js +++ b/src/util/Injected/Utils.js @@ -539,7 +539,7 @@ exports.LoadUtils = () => { chat = null; } } else { - chat = window.Store.Chat.get(chatWid) || (await window.Store.Chat.find(chatWid)); + chat = window.Store.Chat.get(chatWid) || (await window.Store.FindOrCreateChat.findOrCreateLatestChat(chatWid))?.chat; } return getAsModel && chat