fix: Lid is missing in chat table (#3703)
* Use window.Store.FindOrCreateChat.findOrCreateLatestChat to get chat * refactor: change find to findOrCreateLatestChat * refactor: update 'injectToFunction' to support nested props in modules * fix: resolve 'Lid is missing in chat table' error --------- Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
parent
c89cb56593
commit
5276e30ac6
2 changed files with 13 additions and 5 deletions
|
|
@ -102,6 +102,7 @@ exports.ExposeStore = () => {
|
||||||
window.Store.PinnedMsgUtils = window.require('WAWebSendPinMessageAction');
|
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.Settings = {
|
window.Store.Settings = {
|
||||||
...window.require('WAWebUserPrefsGeneral'),
|
...window.require('WAWebUserPrefsGeneral'),
|
||||||
|
|
@ -210,14 +211,21 @@ exports.ExposeStore = () => {
|
||||||
* @param {Function} callback Modified function
|
* @param {Function} callback Modified function
|
||||||
*/
|
*/
|
||||||
window.injectToFunction = (target, callback) => {
|
window.injectToFunction = (target, callback) => {
|
||||||
const module = window.require(target.module);
|
let module = window.require(target.module);
|
||||||
const originalFunction = module[target.function];
|
|
||||||
const modifiedFunction = (...args) => callback(originalFunction, ...args);
|
const path = target.function.split('.');
|
||||||
module[target.function] = modifiedFunction;
|
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: '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: 'WAWebE2EProtoUtils', function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
|
||||||
|
|
||||||
|
window.injectToFunction({ module: 'WAWebLid1X1MigrationGating', function: 'Lid1X1MigrationUtils.isLidMigrated' }, () => false);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -539,7 +539,7 @@ exports.LoadUtils = () => {
|
||||||
chat = null;
|
chat = null;
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
return getAsModel && chat
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue