Skip to content

Commit 843f5b4

Browse files
committed
Fixed Dark Mode and Section States not resetting correctly whenever the user closes the window by clearing the localStorage whenever the user logs in.
1 parent 2988476 commit 843f5b4

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

WebApplication2/Customer/Pages/CustomerComponent.aspx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@
606606
<asp:TextBox ID="TextBoxNationalID" runat="server" Placeholder="Enter your National ID" CssClass="styled-textbox"></asp:TextBox>
607607
<asp:Button ID="ButtonFetchCashback" runat="server" Text="Fetch"
608608
OnClick="btnSubmit_Cashback" CssClass="styled-button" />
609+
<br />
609610
<asp:Label ID="lblCashbackStatus" runat="server"></asp:Label>
610611
</div>
611612
<div class="content" id="remainingExtraAmount">
@@ -700,11 +701,6 @@
700701
}
701702
});
702703
703-
// Clear localStorage on window close
704-
window.addEventListener("beforeunload", function () {
705-
localStorage.clear();
706-
});
707-
708704
// Sortable Table Functionality
709705
document.addEventListener('DOMContentLoaded', function () {
710706
document.querySelectorAll('.styled-table th').forEach(function (th) {
@@ -742,7 +738,6 @@
742738
743739
function logout() {
744740
// Clear the session variable
745-
localStorage.removeItem('activeSection');
746741
localStorage.clear();
747742
// Send a POST request to the logout endpoint
748743
fetch('logout.aspx', { method: 'POST' })

WebApplication2/Customer/Pages/login.aspx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
190190
// Show the pop-up when the page loads
191191
window.onload = function () {
192+
localStorage.clear();
192193
// Check if the user is visiting for the first time in this session
193194
if (!sessionStorage.getItem('closedCustomerLogin')) {
194195
showPopup();

WebApplication2/Pages/Login/Login.aspx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
179179
// Show the pop-up when the page loads
180180
window.onload = function () {
181+
localStorage.clear();
181182
// Check if the user is visiting for the first time in this session
182183
if (!sessionStorage.getItem('closedAdmin')) {
183184
showPopup();

0 commit comments

Comments
 (0)