Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/utils/hooks/useChangedQuerySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ export const useChangedQuerySettings = () => {
const [lastQuerySettings] = useLastQueryExecutionSettings();
const [currentQuerySettings] = useQueryExecutionSettings();

const changedLastExucutionSettings = lastQuerySettings
const changedLastExecutionSettings = lastQuerySettings
? getChangedQueryExecutionSettings(lastQuerySettings, DEFAULT_QUERY_SETTINGS)
: [];

const changedCurrentSettings = currentQuerySettings
? getChangedQueryExecutionSettings(currentQuerySettings, DEFAULT_QUERY_SETTINGS)
: [];

const hasChangedLastExucutionSettings = changedLastExucutionSettings.length > 0;
const hasChangedImportantSettings =
changedLastExecutionSettings.includes('transactionMode') ||
changedLastExecutionSettings.includes('queryMode');

const changedLastExecutionSettingsDescriptions = lastQuerySettings
? getChangedQueryExecutionSettingsDescription({
Expand All @@ -42,23 +44,21 @@ export const useChangedQuerySettings = () => {
bannerLastClosedTimestamp &&
Date.now() - bannerLastClosedTimestamp < WEEK_IN_SECONDS * 1000;

const isBannerShown = hasChangedLastExucutionSettings && !isClosedRecently;
const isIndicatorShown = hasChangedLastExucutionSettings && isClosedRecently;
const isBannerShown = hasChangedImportantSettings && !isClosedRecently;

const closeBanner = () => setBannerLastClosedTimestamp(Date.now());

const resetBanner = () => setBannerLastClosedTimestamp(undefined);

return {
isBannerShown,
isIndicatorShown,
closeBanner,
resetBanner,

changedCurrentSettings,
changedCurrentSettingsDescriptions,

changedLastExucutionSettings,
changedLastExecutionSettings,
changedLastExecutionSettingsDescriptions,
};
};
Loading