Add support for default notification time (icon without specified time)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import dayjs from "dayjs";
|
||||
import { NotificationDatabase } from "../types/notification";
|
||||
import { Notification, NotificationDatabase } from "../types/notification";
|
||||
import { Config } from "../types/config";
|
||||
import { NtfySH } from "./ntfy";
|
||||
import { Debug } from "./debug";
|
||||
@@ -14,9 +14,20 @@ const backends = [
|
||||
* and triggers the notification using specified backends in the config.
|
||||
*/
|
||||
export async function remind(config: Config, db: NotificationDatabase) {
|
||||
const now = dayjs().format("HH:mm");
|
||||
const notifications = db[now] ?? [];
|
||||
const now = dayjs().format("HH:mm");
|
||||
|
||||
await run(config, db, db[now]);
|
||||
|
||||
if(config?.defaultTime && config?.defaultTime === now) {
|
||||
run(config, db, db.default);
|
||||
}
|
||||
}
|
||||
|
||||
async function run(config: Config, db: NotificationDatabase, notifications?: Notification[]) {
|
||||
if(!notifications) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const notification of notifications) {
|
||||
console.info(`Dispatching a notification: [${notification.text}]`)
|
||||
for (const backend of backends) {
|
||||
|
||||
Reference in New Issue
Block a user