notifications: make update alerts non-persistent

once acked, they remain acked. no need to keep nagging the user about them.
This commit is contained in:
Girish Ramakrishnan
2023-03-26 15:12:00 +02:00
parent 9182b01fe0
commit 8205beeabf
8 changed files with 38 additions and 25 deletions

View File

@@ -225,25 +225,26 @@ async function backupFailed(eventId, taskId, errorMessage) {
}
// id is unused but nice to search code
async function alert(id, title, message) {
async function alert(id, title, message, options) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof title, 'string');
assert.strictEqual(typeof message, 'string');
assert.strictEqual(typeof options, 'object');
const result = await getByTitle(title);
if (!result) {
return await add(title, message, { eventId: null });
} else {
await update(result, {
eventId: null,
title,
message,
acknowledged: false,
creationTime: new Date()
});
return result.id;
}
if (!result) return await add(title, message, { eventId: null });
if (!options.persist) return result.id;
await update(result, {
id: result.id,
eventId: null,
title,
message,
acknowledged: false,
creationTime: new Date()
});
return result.id;
}
// id is unused but nice to search code