Initial commit
This commit is contained in:
19
src/main/state-actions.ts
Normal file
19
src/main/state-actions.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { BrowserWindow } from 'electron'
|
||||
import { IPC } from '@shared/ipc'
|
||||
import { getExercises, getState, updateExercise } from './store'
|
||||
|
||||
export function broadcastState(): void {
|
||||
const state = getState()
|
||||
for (const win of BrowserWindow.getAllWindows()) {
|
||||
if (!win.isDestroyed()) win.webContents.send(IPC.evtStateChanged, state)
|
||||
}
|
||||
}
|
||||
|
||||
export function snoozeAll(minutes: number): void {
|
||||
const now = Date.now()
|
||||
for (const ex of getExercises()) {
|
||||
if (!ex.enabled) continue
|
||||
updateExercise(ex.id, { nextFireAt: now + minutes * 60_000 })
|
||||
}
|
||||
broadcastState()
|
||||
}
|
||||
Reference in New Issue
Block a user