1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Electron: Getting notifications to work

This commit is contained in:
Laurent Cozic
2017-11-28 00:22:38 +00:00
parent 7df6541902
commit 6e23fead59
10 changed files with 131 additions and 35 deletions

View File

@@ -14,16 +14,14 @@ class Alarm extends BaseModel {
return this.modelSelectOne('SELECT * FROM alarms WHERE note_id = ?', [noteId]);
}
static async garbageCollect() {
// Delete alarms that have already been triggered
await this.db().exec('DELETE FROM alarms WHERE trigger_time <= ?', [Date.now()]);
static async deleteExpiredAlarms() {
return this.db().exec('DELETE FROM alarms WHERE trigger_time <= ?', [Date.now()]);
}
// Delete alarms that correspond to non-existent notes
static async alarmIdsWithoutNotes() {
// https://stackoverflow.com/a/4967229/561309
await this.db().exec('DELETE FROM alarms WHERE id IN (SELECT alarms.id FROM alarms LEFT JOIN notes ON alarms.note_id = notes.id WHERE notes.id IS NULL)');
// TODO: Check for duplicate alarms for a note
// const rows = await this.db().exec('SELECT count(*) as note_count, note_id from alarms group by note_id having note_count >= 2');
const alarms = await this.db().selectAll('SELECT alarms.id FROM alarms LEFT JOIN notes ON alarms.note_id = notes.id WHERE notes.id IS NULL');
return alarms.map((a) => { return a.id });
}
}

View File

@@ -422,7 +422,7 @@ class Note extends BaseItem {
}
static dueNotes() {
return this.modelSelectAll('SELECT id, title, body, todo_due FROM notes WHERE is_conflict = 0 AND is_todo = 1 AND todo_completed = 0 AND todo_due > ?', [time.unixMs()]);
return this.modelSelectAll('SELECT id, title, body, is_todo, todo_due, todo_completed, is_conflict FROM notes WHERE is_conflict = 0 AND is_todo = 1 AND todo_completed = 0 AND todo_due > ?', [time.unixMs()]);
}
static needAlarm(note) {