Skip to content

Commit

Permalink
chore(pages/home): slightly optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeysova committed Jun 28, 2022
1 parent d908ddd commit 971f059
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pages/home/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attach, createEvent, createStore, guard, sample } from 'effector';
import { attach, createEvent, createStore, sample } from 'effector';
import { not } from 'patronum';

import { historyPush } from 'features/navigation';
Expand All @@ -18,6 +18,8 @@ export const $showError = createStore<boolean>(false);
const sessionDeleteFx = attach({ effect: api.sessionDelete });
const pageReady = checkAuthenticated({ when: pageStarted });

$showError.reset(pageReady);

sample({
clock: $session,
fn: (session) => `${session?.firstName} ${session?.lastName}`,
Expand All @@ -38,9 +40,9 @@ sample({
});

sample({
clock: api.sessionDelete.done,
clock: sessionDeleteFx.done,
fn: (_) => '/login',
target: historyPush,
});

$showError.reset(pageReady).on(sessionDeleteFx.fail, (_) => true);
$showError.on(sessionDeleteFx.fail, () => true);

0 comments on commit 971f059

Please sign in to comment.