Squashed commit of the following:
fix: fixed storage
added hyper torture condition for the fail modal window
Added separate streak funtionality for hyper torture mode
added image and popup modal with haha funny image
Merge branch 'main' into hyper_torture
changed index popup for hyperTorture mode
added hyperTorture streak saving/updating
hyper torture mode redirect logic done
Added hypertorture mode messages and UI elements
Updated styles for #solved-message, #unsolved-message, and added #hyperTorture-message.
Reasons for Changes Across All Files
background.ts
Adding More Functions: New functions from the storage file have been included. These additional functions are needed for new features like "Hyper Torture Mode" and notifications for incorrect answers.
Introducing Hyper Torture Mode: We introduce a feature called "Hyper Torture Mode". When activated, users who try to navigate to another page are automatically sent to a problem on LeetCode. They can only return to their original page after solving the problem. This loop continues until the user turns off the mode. Special coding techniques were used for this, such as a code snippet that keeps track of attempted URLs. The URL listener is set up in the toggleUrlListener function. It listens for any request made by the user and saves the URL of the request. This URL is then used to redirect the user back to their desired page once they have solved the problem.
Better Feedback for Mistakes: A new feature informs users when they've answered incorrectly. If a user fails to solve a problem, a message appears to let them know. This is done with a function named sendUserFailedMessage, which uses browser capabilities to show the alert.
FailImage.tsx
New File Creation: To display images based on conditional logic, part of the "Failed Submissions" feature.
SettingDrawer.tsx
New Variables and Mode: To accommodate the "Hyper Torture Mode", enabling or disabling the feature.
FailedModal.tsx
New File Creation: To display a modal when a user fails a problem, aiming to improve user engagement and experience.
modal.css
New CSS Rules: To style the "FailedModal" component for visual consistency.
popup.tsx
Inclusion of Hyper Torture Mode: To challenge users with a new feature.
storage.ts
Streak Calculations and Type Conversion: The original code in storage.ts used Promise.all() for both retrieving the bestStreak and calculating the newStreak.
This could lead to race conditions, type errors, and NaN (Not a Number) issues for the following reasons:
Race Condition: The usage of Promise.all() implies that all the promises inside it execute concurrently. This could lead to incorrect values for bestStreak and newStreak if they depend on each other or external factors.
Type Errors and NaN Handling: While the original code did use Number() conversion, it was intertwined with the Promise.all() logic. This could potentially lead to a type mismatch or NaN values, especially if the value returned from the storage is not a number.
By moving the Number() conversion directly to the calculation steps of HT_currentStreak and currentStreak, the new code ensures that these variables are always numbers before incrementing, thus preventing NaN issues.
Squashed commit of the following: fix: fixed storage added hyper torture condition for the fail modal window Added separate streak funtionality for hyper torture mode added image and popup modal with haha funny image Merge branch 'main' into hyper_torture changed index popup for hyperTorture mode added hyperTorture streak saving/updating hyper torture mode redirect logic done Added hypertorture mode messages and UI elements
Closes #89
Update Summary
Table of Contents
Files Updated
storage
imported; added "Hyper Torture Mode" and handling for failed submissions.storage.ts
.#solved-message
,#unsolved-message
, and added#hyperTorture-message
.Reasons for Changes Across All Files
background.ts
Adding More Functions: New functions from the
storage
file have been included. These additional functions are needed for new features like "Hyper Torture Mode" and notifications for incorrect answers.Introducing Hyper Torture Mode: We introduce a feature called "Hyper Torture Mode". When activated, users who try to navigate to another page are automatically sent to a problem on LeetCode. They can only return to their original page after solving the problem. This loop continues until the user turns off the mode. Special coding techniques were used for this, such as a code snippet that keeps track of attempted URLs. The URL listener is set up in the
toggleUrlListener
function. It listens for any request made by the user and saves the URL of the request. This URL is then used to redirect the user back to their desired page once they have solved the problem.Better Feedback for Mistakes: A new feature informs users when they've answered incorrectly. If a user fails to solve a problem, a message appears to let them know. This is done with a function named sendUserFailedMessage, which uses browser capabilities to show the alert.
FailImage.tsx
SettingDrawer.tsx
FailedModal.tsx
modal.css
popup.tsx
storage.ts
Streak Calculations and Type Conversion: The original code in
storage.ts
usedPromise.all()
for both retrieving thebestStreak
and calculating thenewStreak
.This could lead to race conditions, type errors, and NaN (Not a Number) issues for the following reasons:
Race Condition: The usage of
Promise.all()
implies that all the promises inside it execute concurrently. This could lead to incorrect values forbestStreak
andnewStreak
if they depend on each other or external factors.Type Errors and NaN Handling: While the original code did use
Number()
conversion, it was intertwined with thePromise.all()
logic. This could potentially lead to a type mismatch or NaN values, especially if the value returned from thestorage
is not a number.By moving the
Number()
conversion directly to the calculation steps ofHT_currentStreak
andcurrentStreak
, the new code ensures that these variables are always numbers before incrementing, thus preventing NaN issues.styles.css