Skip to content

Commit

Permalink
fix: pullrequest without the files, uh ?
Browse files Browse the repository at this point in the history
  • Loading branch information
Teyk0o committed Nov 23, 2024
1 parent 2de06ee commit b3abdf1
Show file tree
Hide file tree
Showing 3 changed files with 746 additions and 351 deletions.
46 changes: 33 additions & 13 deletions src/content.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setupMentions } from "./modules/mentions.js";
//import { setupReactions } from "./modules/reactions.js";
import { reactionManager } from "./modules/reactions.js";
import { checkNewMessages, observer } from "./utils/observer.js";

/**
Expand All @@ -13,21 +13,41 @@ const app = {
},

init: ()=> {
console.log('WWSNB by Théo Vilain successfully loaded');
console.log('WWSNB by Théo Vilain successfully loaded');


// Start observing document for changes
observer.observe(document.body, app.config);
// Initialize all modules with a slight delay to ensure DOM is ready
setTimeout(() => {
console.log('[WWSNB] Starting modules initialization');
checkNewMessages();
setupMentions();
//setupReactions();
console.log('[WWSNB] Modules initialized successfully');
}, 1000);
// Start observing document for changes
observer.observe(document.body, app.config);
// Initialize all modules with a slight delay to ensure DOM is ready
setTimeout(() => {
console.log('[WWSNB] Starting modules initialization');
checkNewMessages();
setupMentions();
reactionManager.setup();
console.log('[WWSNB] Modules initialized successfully');
}, 1000);

// Add cleanup handlers
window.addEventListener('beforeunload', app.cleanup);
window.addEventListener('unload', app.cleanup);

},

cleanup: (event?: BeforeUnloadEvent | Event) => {
console.log('[WWSNB] Cleaning up...');

const isRefresh = event?.type === 'beforeunload';

observer.disconnect();
reactionManager.cleanup(isRefresh);

console.log('[WWSNB] Cleanup completed');
}
}

// Launch the application when DOM is ready
document.readyState === 'loading'? document.addEventListener('DOMContentLoaded', app.init) : app.init();
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', app.init);
} else {
app.init();
}
Loading

0 comments on commit b3abdf1

Please sign in to comment.