Skip to content

Commit

Permalink
Removed async from differenceInDays since it's redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
doracretu3pillar committed Sep 25, 2024
1 parent 873bf02 commit 2a4b943
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 = {
Expand Down Expand Up @@ -108,7 +106,7 @@ const PerconaUpdateVersion: FC = () => {
{changeLogs?.updates.map((update: UpdatesChangelogs) => (
<li key={update.toString()}>
<a href={update.releaseNotesUrl}>
{update.version}, {dateTimeFormat(update.timestamp, { format: 'MMM DD, YYYY' })}
{update.version}, {dateTimeFormat(update.timestamp, { format: 'MMM DD, YYYY' })}
</a>
</li>
))}
Expand Down
1 change: 1 addition & 0 deletions public/app/percona/shared/core/reducers/updates/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const updatesSlice = createSlice({
updateAvailable: true, // to remove
latest: { version: '3.0.1' }, // to remove
isLoading: false,
lastChecked: '',
}));

builder.addCase(checkUpdatesAction.rejected, (state) => ({
Expand Down

0 comments on commit 2a4b943

Please sign in to comment.