Skip to content

Commit

Permalink
Fix endless loop when height updates
Browse files Browse the repository at this point in the history
  • Loading branch information
timolins committed Dec 31, 2024
1 parent c3d6739 commit 2e1129c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ export const reducer = (state: State, action: Action): State => {
return {
...state,
toasts: state.toasts.map((t) =>
t.id === action.toast.id
? { ...t, dismissed: false, visible: true, ...action.toast }
: t
t.id === action.toast.id ? { ...t, ...action.toast } : t
),
};

case ActionType.UPSERT_TOAST:
const { toast } = action;
return state.toasts.find((t) => t.id === toast.id)
? reducer(state, { type: ActionType.UPDATE_TOAST, toast })
: reducer(state, { type: ActionType.ADD_TOAST, toast });
return reducer(state, {
type: state.toasts.find((t) => t.id === toast.id)
? ActionType.UPDATE_TOAST
: ActionType.ADD_TOAST,
toast,
});

case ActionType.DISMISS_TOAST:
const { toastId } = action;
Expand Down

3 comments on commit 2e1129c

@hanhnguyen694
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright Β© OK365.com Reserved

@hanhnguyen694
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A

@hanhnguyen694
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.