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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user