Skip to content

Commit

Permalink
fix: Fixed WhatsApp WEB loading error (fix #1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jul 28, 2023
1 parent 5481e01 commit 433f939
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
15 changes: 0 additions & 15 deletions src/chat/patch.ts
Expand Up @@ -83,18 +83,3 @@ function applyPatch() {
return func(...args);
});
}

/**
* Fix for buttons for @whatsapp >= 2.2234.6
* This is an erro in whatsapp javascript files
*/
webpack.onInjected(() => {
if ('stylex' in (window as any)) {
return;
}
const stylexModule = webpack.search((m) => m.default.dedupe);
if (!stylexModule?.default) {
return;
}
(window as any).stylex = stylexModule?.default;
});
10 changes: 4 additions & 6 deletions src/webpack/index.ts
Expand Up @@ -30,12 +30,10 @@ export let isInjected = false;
*/
export let isReady = false;

export function onInjected(listener: () => void): void {
internalEv.on('webpack.injected', async () =>
Promise.resolve()
.then(listener)
.catch(() => null)
);
export function onInjected(listener: () => void, delay = 0): void {
internalEv.on('webpack.injected', () => {
setTimeout(listener, delay);
});
}

export function onReady(listener: () => void): void {
Expand Down

0 comments on commit 433f939

Please sign in to comment.