Skip to content

Commit

Permalink
refactor(clear-storage): clear remaining user/session specific storage
Browse files Browse the repository at this point in the history
  • Loading branch information
domw30 committed Mar 10, 2025
1 parent 3583852 commit 25f989f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/lib/chat/session-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class SessionStorage {
this.storage.removeItem('mxz_device_id');
this.storage.removeItem(`mxz_access_token_${deviceId}`);
this.storage.removeItem('mxz_user_id');

const allKeys = Object.keys(this.storage);
const filterKeys = allKeys.filter((key) => key.includes('mxjssdk_memory_filter'));
filterKeys.forEach((key) => this.storage.removeItem(key));
}

set(session: ChatSession) {
Expand Down
9 changes: 2 additions & 7 deletions src/store/authentication/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { completePendingUserProfile } from '../registration/saga';
import { closeUserProfile } from '../user-profile/saga';
import { clearLastActiveConversation } from '../../lib/last-conversation';
import { clearLastActiveTab } from '../../lib/last-tab';
import { clearIndexedDBStorage } from '../../lib/storage/clear-idb';
import { clearRewards } from '../rewards/saga';

export const currentUserSelector = () => (state) => {
return getDeepProperty(state, 'authentication.user.data', null);
Expand Down Expand Up @@ -57,12 +57,6 @@ export function* terminate(isAccountChange = false) {
/* No operation, if user is unauthenticated deleting the cookie fails */
}

try {
yield call(clearIndexedDBStorage);
} catch (error) {
console.error('Error clearing IndexedDB storage:', error);
}

yield call(clearUserState);
yield call(redirectUnauthenticatedUser, isAccountChange);
yield call(publishUserLogout);
Expand Down Expand Up @@ -119,6 +113,7 @@ export function* forceLogout() {
yield closeLogoutModal();
yield call(clearLastActiveConversation);
yield call(clearLastActiveTab);
yield call(clearRewards);
yield call(terminate);
}

Expand Down
5 changes: 5 additions & 0 deletions src/store/rewards/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export function* closeRewardsTooltip() {
}
}

export const clearRewards = (): void => {
localStorage.removeItem(lastDayRewardsKey);
localStorage.removeItem(totalRewardsKey);
};

export function* transferMeow(action) {
yield put(setTransferError({ error: null }));

Expand Down

0 comments on commit 25f989f

Please sign in to comment.