Skip to content

Commit

Permalink
fix: Fixed conn.main_ready event (#2260)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelo386 authored Aug 24, 2024
1 parent 6876196 commit af5b398
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/conn/events/registerMainReadyEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ import * as webpack from '../../webpack';
import { Cmd, Stream } from '../../whatsapp';

webpack.onInjected(register);
let isMainReady = false;

function register() {
const trigger = async () => {
internalEv.emit('conn.main_ready');
if (!isMainReady) {
isMainReady = true;
setTimeout(() => (isMainReady = false), 1000);
internalEv.emit('conn.main_ready');
}
};

if (Stream.mode === 'MAIN') {
trigger();
} else {
Cmd.on('main_stream_mode_ready', () => trigger);
Cmd.on('main_stream_mode_ready_legacy', trigger);
}
}

0 comments on commit af5b398

Please sign in to comment.