Skip to content

Commit

Permalink
Merge pull request #140 from Team-EverFlow/bugfix/111-badge-system-fix
Browse files Browse the repository at this point in the history
[Fix] #111 - Fixed EventListener
  • Loading branch information
Mule129 authored Aug 18, 2023
2 parents d0e729c + 2258317 commit 8e1878d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/firebase/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ auth.onAuthStateChanged(async user => {
);
if (mybadgeDoc.exists() && mybadgeDoc.data().addedTime) continue;
for (const eventName of badge.data.eventName) {
if (!window.everflowEvents) window.everflowEvents = [eventName];
else window.everflowEvents.push(eventName);
window.addEventListener(eventName, async e => {
console.log(e);
const { success, error } = await UpdateBadgeProgressValue(
Expand Down Expand Up @@ -79,5 +81,10 @@ auth.onAuthStateChanged(async user => {
});
}
}
} else {
if (!window.everflowEvents) return;
for (const event of window.everflowEvents) {
window.removeEventListener(event, () => {});
}
}
});

0 comments on commit 8e1878d

Please sign in to comment.