mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-08-02 12:32:14 +00:00
feat(reminders): add persistence
This commit is contained in:
parent
56cab041e1
commit
44a2b00905
4 changed files with 21 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ export const LS_GLOBAL_CFG = LS_PREFIX + 'GLOBAL_CFG';
|
|||
export const LS_BACKUP = LS_PREFIX + 'COMPLETE_BACKUP';
|
||||
export const LS_LAST_ACTIVE = LS_PREFIX + 'LAST_ACTIVE';
|
||||
export const LS_LAYOUT = LS_PREFIX + 'LAYOUT';
|
||||
export const LS_REMINDER = LS_PREFIX + 'REMINDER';
|
||||
|
||||
export const LS_PROJECT_META_LIST = LS_PREFIX + 'PROJECT_META_LIST';
|
||||
export const LS_PROJECT_CFG: ProjectDataLsKey = 'CFG';
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
LS_NOTE_STATE,
|
||||
LS_PROJECT_META_LIST,
|
||||
LS_PROJECT_PREFIX,
|
||||
LS_REMINDER,
|
||||
LS_TASK_ARCHIVE,
|
||||
LS_TASK_ATTACHMENT_STATE,
|
||||
LS_TASK_STATE
|
||||
|
|
@ -24,6 +25,7 @@ import { AppDataComplete } from '../sync/sync.model';
|
|||
import { BookmarkState } from '../../bookmark/store/bookmark.reducer';
|
||||
import { AttachmentState } from '../../tasks/attachment/store/attachment.reducer';
|
||||
import { NoteState } from '../../note/store/note.reducer';
|
||||
import { Reminder } from '../../reminder/reminder.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
|
@ -42,6 +44,14 @@ export class PersistenceService {
|
|||
saveToLsWithLastActive(LS_PROJECT_META_LIST, projectData);
|
||||
}
|
||||
|
||||
loadReminders(): Reminder[] {
|
||||
return loadFromLs(LS_REMINDER);
|
||||
}
|
||||
|
||||
saveReminders(reminders: Reminder[]) {
|
||||
saveToLsWithLastActive(LS_REMINDER, reminders);
|
||||
}
|
||||
|
||||
saveTasksForProject(projectId, taskState: TaskState) {
|
||||
saveToLsWithLastActive(this._makeProjectKey(projectId, LS_TASK_STATE), taskState);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<form (submit)="save()">
|
||||
<mat-dialog-content>
|
||||
<h2 class="mat-h2">{{isEdit ? 'Edit' : 'Add'}} reminder
|
||||
reminder for note</h2>
|
||||
<h2 class="mat-h2">{{isEdit ? 'Edit' : 'Add'}} reminder for note</h2>
|
||||
|
||||
<mat-form-field>
|
||||
<!--[matDatepicker]="myDatepicker"-->
|
||||
|
|
|
|||
|
|
@ -52,17 +52,20 @@ export class ReminderService {
|
|||
});
|
||||
// this._persistenceService
|
||||
this._updateRemindersInWorker(this._reminders);
|
||||
this._saveToLS(this._reminders);
|
||||
console.log(this._reminders);
|
||||
return id;
|
||||
}
|
||||
|
||||
updateReminder(reminderChanges: Partial<Reminder>) {
|
||||
updateReminder(reminderId: string, reminderChanges: Partial<Reminder>) {
|
||||
this._saveToLS(this._reminders);
|
||||
}
|
||||
|
||||
removeReminder(reminderIdToRemove: string) {
|
||||
const i = this._reminders.findIndex(reminder => reminder.id === reminderIdToRemove);
|
||||
if (i > -1) {
|
||||
this._reminders.splice(i, 1);
|
||||
this._saveToLS(this._reminders);
|
||||
} else {
|
||||
throw new Error('Unable to find reminder with id ' + reminderIdToRemove);
|
||||
}
|
||||
|
|
@ -82,8 +85,11 @@ export class ReminderService {
|
|||
}
|
||||
|
||||
private _loadFromLs(): Reminder[] {
|
||||
// this._persistenceService.
|
||||
return [];
|
||||
return this._persistenceService.loadReminders() || [];
|
||||
}
|
||||
|
||||
private _saveToLS(reminders: Reminder[]) {
|
||||
this._persistenceService.saveReminders(reminders);
|
||||
}
|
||||
|
||||
private _updateRemindersInWorker(reminders: Reminder[]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue