Skip to content

Commit

Permalink
Make sure we're not creating a saved search while a previous creation…
Browse files Browse the repository at this point in the history
… call is in progress
  • Loading branch information
janmonschke committed Jan 15, 2024
1 parent 232fae2 commit e770e35
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ export const useDiscoverInTimelineActions = (
} else {
// If no saved search exists. Create a new saved search instance and associate it with the timeline.
try {
// Make sure we're not creating a saved search while a previous creation call is in progress
if (status !== 'idle') {
return;
}
dispatch(
timelineActions.startTimelineSaving({
id: TimelineId.active,
Expand All @@ -218,7 +222,7 @@ export const useDiscoverInTimelineActions = (
const responseIsEmpty = !response || !response?.id;
if (responseIsEmpty) {
throw new Error('Response is empty');
} else if (!savedSearchId && !responseIsEmpty && status !== 'loading') {
} else if (!savedSearchId && !responseIsEmpty) {
dispatch(
timelineActions.updateSavedSearchId({
id: TimelineId.active,
Expand Down

0 comments on commit e770e35

Please sign in to comment.