From ad54876fa7bc5d0152b131456adb3dfa80296d24 Mon Sep 17 00:00:00 2001 From: Fauzan Haq <55099255+fznhq@users.noreply.github.com> Date: Fri, 5 Aug 2022 15:30:17 +0700 Subject: [PATCH] feat: remove unused addChatID and fix preload startup detection (#204) --- src/preload.js | 18 ++---------------- src/util/webview/addChatIDs.js | 16 ---------------- 2 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 src/util/webview/addChatIDs.js diff --git a/src/preload.js b/src/preload.js index d7be0f49..a9da86d8 100644 --- a/src/preload.js +++ b/src/preload.js @@ -102,27 +102,13 @@ window.onload = () => { new MutationObserver((mutations) => { // Check when WhatsApp is done loading - if ( - mutations[0].removedNodes.length > 0 && - mutations[0].removedNodes[0].id === "startup" - ) { - addChatIDs(); - - // Update chat IDs when a chat is added/removed. - new MutationObserver(() => { - addChatIDs(); - }).observe( - document.querySelector('#pane-side [role="region"]', { - subtree: true, - childList: true, - }) - ); + if (mutations[0].removedNodes[0]?.innerHTML.includes("progress")) { // Remove "Update available" message if ( document.querySelector("._3z9_h").innerText.includes("Update available") ) { - document.querySelector("._3z9_h").style.display = "none"; + document.querySelector("._3z9_h").firstChild.remove() } } diff --git a/src/util/webview/addChatIDs.js b/src/util/webview/addChatIDs.js deleted file mode 100644 index 5a32a903..00000000 --- a/src/util/webview/addChatIDs.js +++ /dev/null @@ -1,16 +0,0 @@ -const addChatIDs = () => { - if (document.querySelectorAll('#pane-side [role="region"] > *').length > 0) { - document - .querySelectorAll('#pane-side [role="region"] > *') - .forEach((chat) => { - let internalInstance = - chat[ - Object.keys(chat).find((key) => key.includes("InternalInstance")) - ]; - let id = - internalInstance.memoizedProps.children.props.contact.id._serialized; - chat.id = id; - }); - } -}; -module.exports = addChatIDs;