From 2a4b943902ad4a7e63ae060cc916b00eccce17f5 Mon Sep 17 00:00:00 2001 From: DoraCretu594118 <103416234+doracretu3pillar@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:20:11 +0300 Subject: [PATCH] Removed async from differenceInDays since it's redundant --- .../PerconaUpdateVersion.styles.ts | 2 +- .../PerconaUpdateVersion.test.tsx | 0 .../PerconaUpdateVersion.tsx | 24 +++++++++---------- .../shared/core/reducers/updates/updates.ts | 1 + 4 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts index e5519179be45c..5a58800272732 100644 --- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts +++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts @@ -27,7 +27,7 @@ export const getStyles = ({ v1: { spacing, colors } }: GrafanaTheme2) => ({ notesTitle: css` font-weight: 500; font-size: 16px; - margin-top: 27px + margin-top: 27px; `, updateButtons: css` margin-top: 35px; diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx index 857769ba319df..84dd606035961 100644 --- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx +++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx @@ -25,12 +25,11 @@ const PerconaUpdateVersion: FC = () => { useEffect(() => { const showModal = async () => { - console.log('checkUpdatesChangelogs'); await dispatch(checkUpdatesChangeLogs()); setShowUpdate(true); }; - const differenceInDays = async () => { + const differenceInDays = () => { if (lastChecked) { const lastCheckDate = new Date(lastChecked); const currentDate = new Date(); @@ -45,19 +44,18 @@ const PerconaUpdateVersion: FC = () => { if (!snoozeCurrentVersion) { dispatch(getSnoozeCurrentVersion()); } - differenceInDays().then((days) => { - if ( - (installed?.version !== latest?.version /*days > 6 &&*/ && - snoozeCurrentVersion?.snoozedPmmVersion !== latest?.version) || - !lastChecked - ) { - showModal(); - } - }); + const days = differenceInDays(); + if ( + (installed?.version !== latest?.version && + days > 6 && + snoozeCurrentVersion?.snoozedPmmVersion !== latest?.version) || + !lastChecked + ) { + showModal(); + } } }, [dispatch, updateAvailable, installed, latest, snoozeCurrentVersion, lastChecked]); - // Snooze API const snoozeUpdate = async () => { if (latest && latest.version) { const payload = { @@ -108,7 +106,7 @@ const PerconaUpdateVersion: FC = () => { {changeLogs?.updates.map((update: UpdatesChangelogs) => (