Use non-string comparison
This commit is contained in:
@@ -27,3 +27,14 @@ export function toSimpleDateString(date: Date | string): string {
|
|||||||
const _date = typeof date === 'string' ? new Date(date) : date
|
const _date = typeof date === 'string' ? new Date(date) : date
|
||||||
return _date.toISOString().split('T')[0]
|
return _date.toISOString().split('T')[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares two dates by year, month, and day only
|
||||||
|
*/
|
||||||
|
export function simpleAreDatesEqual(a: Date, b: Date): boolean {
|
||||||
|
return (
|
||||||
|
a.getFullYear() === b.getFullYear() &&
|
||||||
|
a.getMonth() === b.getMonth() &&
|
||||||
|
a.getDate() === b.getDate()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {toSimpleDateString} from '#/lib/strings/time'
|
import {simpleAreDatesEqual} from '#/lib/strings/time'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
import {SessionAccount} from '../session'
|
import {SessionAccount} from '../session'
|
||||||
@@ -12,9 +12,8 @@ export function shouldRequestEmailConfirmation(account: SessionAccount) {
|
|||||||
// wait for onboarding to complete
|
// wait for onboarding to complete
|
||||||
if (isOnboardingActive()) return false
|
if (isOnboardingActive()) return false
|
||||||
|
|
||||||
const stored = persisted.get('reminders').lastEmailConfirm
|
const snoozedAt = persisted.get('reminders').lastEmailConfirm
|
||||||
const snoozedAt = stored ? toSimpleDateString(new Date(stored)) : undefined
|
const today = new Date()
|
||||||
const today = toSimpleDateString(new Date())
|
|
||||||
|
|
||||||
logger.debug('Checking email confirmation reminder', {
|
logger.debug('Checking email confirmation reminder', {
|
||||||
today,
|
today,
|
||||||
@@ -28,7 +27,7 @@ export function shouldRequestEmailConfirmation(account: SessionAccount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// already snoozed today
|
// already snoozed today
|
||||||
if (snoozedAt === today) {
|
if (simpleAreDatesEqual(new Date(snoozedAt), new Date())) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user