Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(clear-storage): clear remaining user/session specific storage #2759

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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