Skip to content

Commit

Permalink
fix: remove unnecessary localstorage key
Browse files Browse the repository at this point in the history
  • Loading branch information
naumovski-filip committed Sep 13, 2023
1 parent f3b9473 commit 1a504b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
9 changes: 1 addition & 8 deletions src/hooks/useProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import { createProfile, deleteProfile, enterProfile, listProfiles, updateProfile
import { useProfileStore } from '#src/stores/ProfileStore';
import { useWatchHistoryStore } from '#src/stores/WatchHistoryStore';
import * as persist from '#src/utils/persist';
import type { AuthData, CommonAccountResponse, ListProfilesResponse, ProfileDetailsPayload, ProfilePayload } from '#types/account';
import type { CommonAccountResponse, ListProfilesResponse, ProfileDetailsPayload, ProfilePayload } from '#types/account';
import { useAccountStore } from '#src/stores/AccountStore';

const PERSIST_KEY_ACCOUNT = 'auth';
const PERSIST_PROFILE = 'profile';

export const unpersistProfile = () => {
persist.removeItem(PERSIST_PROFILE);
persist.removeItem(PERSIST_KEY_ACCOUNT);
};

export const useSelectProfile = () => {
Expand All @@ -29,11 +27,6 @@ export const useSelectProfile = () => {
onSuccess: async (response) => {
const profile = response?.responseData;
if (profile?.credentials?.access_token) {
const authData: AuthData = {
jwt: profile.credentials.access_token,
refreshToken: '',
};
persist.setItem(PERSIST_KEY_ACCOUNT, authData);
persist.setItem(PERSIST_PROFILE, profile);
persist.setItemStorage('inplayer_token', {
expires: profile.credentials.expires,
Expand Down
2 changes: 0 additions & 2 deletions src/stores/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import type {
import type { Offer } from '#types/checkout';
import { unpersistProfile } from '#src/hooks/useProfiles';

const PERSIST_KEY_ACCOUNT = 'auth';
const PERSIST_PROFILE = 'profile';

export const initializeAccount = async () => {
Expand Down Expand Up @@ -181,7 +180,6 @@ async function clearLoginState() {

export async function logout(logoutOptions: { includeNetworkRequest: boolean } = { includeNetworkRequest: true }) {
await useService(async ({ accountService }) => {
persist.removeItem(PERSIST_KEY_ACCOUNT);
persist.removeItem(PERSIST_PROFILE);

// this invalidates all entitlements caches which makes the useEntitlement hook to verify the entitlements.
Expand Down

0 comments on commit 1a504b5

Please sign in to comment.