about summary refs log tree commit diff
path: root/src/components/dialogs/nuxs/snoozing.ts
blob: 91effd050163c0de0d8b736ff1fb173eebdbe973 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import {simpleAreDatesEqual} from '#/lib/strings/time'
import {device} from '#/storage'

export function snooze() {
  device.set(['lastNuxDialog'], new Date().toISOString())
}

export function unsnooze() {
  device.set(['lastNuxDialog'], undefined)
}

export function isSnoozed() {
  const lastNuxDialog = device.get(['lastNuxDialog'])
  if (!lastNuxDialog) return false
  const last = new Date(lastNuxDialog)
  const now = new Date()
  // already snoozed today
  if (simpleAreDatesEqual(last, now)) {
    return true
  }
  return false
}