Skip to content

Commit

Permalink
fix: restore personal shelves after registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Feb 20, 2024
1 parent dd8d484 commit 3fdb220
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/common/src/controllers/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ export default class AccountController {

if (authData) {
await this.getAccount();
await this.watchHistoryController.restoreWatchHistory();
await this.favoritesController.restoreFavorites();
}
} catch (error: unknown) {
logDev('Failed to get user', error);
Expand Down Expand Up @@ -145,10 +143,9 @@ export default class AccountController {

try {
const response = await this.accountService.getUser({ config });

if (response) {
await this.afterLogin(response.user, response.customerConsents);
await this.favoritesController.restoreFavorites().catch(logDev);
await this.watchHistoryController.restoreWatchHistory().catch(logDev);
}

useAccountStore.setState({ loading: false });
Expand Down Expand Up @@ -289,7 +286,10 @@ export default class AccountController {

const updatedCustomer = await this.accountService.updateCaptureAnswers({ customer, ...capture });

await this.afterLogin(updatedCustomer, customerConsents, false);
useAccountStore.setState({
user: updatedCustomer,
customerConsents,
});

return updatedCustomer;
};
Expand Down Expand Up @@ -499,7 +499,12 @@ export default class AccountController {
customerConsents,
});

await Promise.allSettled([shouldReloadSubscription ? this.reloadSubscriptions() : Promise.resolve(), this.getPublisherConsents()]);
await Promise.allSettled([
shouldReloadSubscription ? this.reloadSubscriptions() : Promise.resolve(),
this.getPublisherConsents(),
this.favoritesController.restoreFavorites(),
this.watchHistoryController.restoreWatchHistory(),
]);
useAccountStore.setState({ loading: false });
}

Expand Down Expand Up @@ -533,7 +538,7 @@ export default class AccountController {

this.profileController.unpersistProfile();

await this.favoritesController.restoreFavorites().catch(logDev);
await this.watchHistoryController.restoreWatchHistory().catch(logDev);
await this.favoritesController.restoreFavorites();
await this.watchHistoryController.restoreWatchHistory();
};
}

0 comments on commit 3fdb220

Please sign in to comment.