refactor: remove wwebjs patch

This commit is contained in:
Anton Voylenko 2025-09-06 12:19:33 +03:00
commit 1200abd9c8

View file

@ -144,32 +144,6 @@ const patchWWebLibrary = async (client) => {
filteredChats.map(chat => window.WWebJS.getChatModel(chat))
)
}
// hotfix for https://github.com/pedroslopez/whatsapp-web.js/pull/3703
window.Store.FindOrCreateChat = window.require('WAWebFindChatAction')
window.WWebJS.getChat = async (chatId, { getAsModel = true } = {}) => {
const isChannel = /@\w*newsletter\b/.test(chatId)
const chatWid = window.Store.WidFactory.createWid(chatId)
let chat
if (isChannel) {
try {
chat = window.Store.NewsletterCollection.get(chatId)
if (!chat) {
await window.Store.ChannelUtils.loadNewsletterPreviewChat(chatId)
chat = await window.Store.NewsletterCollection.find(chatWid)
}
} catch (err) {
chat = null
}
} else {
chat = window.Store.Chat.get(chatWid) || (await window.Store.FindOrCreateChat.findOrCreateLatestChat(chatWid))?.chat
}
return getAsModel && chat
? await window.WWebJS.getChatModel(chat, { isChannel })
: chat
}
})
}