mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 23:39:50 -04:00
Update Saved pages
This commit is contained in:
parent
fb269968ad
commit
b020f09fd4
@ -64,6 +64,10 @@ export class AppComponent extends SubscriberComponent implements AfterViewInit {
|
|||||||
this.dialog.open(PageEditModalComponent);
|
this.dialog.open(PageEditModalComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePage() {
|
||||||
|
this.appService.updatePage();
|
||||||
|
}
|
||||||
|
|
||||||
createNote() {
|
createNote() {
|
||||||
this.dialog.open(NoteEditModalComponent);
|
this.dialog.open(NoteEditModalComponent);
|
||||||
}
|
}
|
||||||
|
@ -317,6 +317,39 @@ export class AppService extends createStateService(reducer, initialState) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePage() {
|
||||||
|
const state = this.getState();
|
||||||
|
|
||||||
|
const savedPages = [
|
||||||
|
...state.savedPages.filter((o) => o.id === state.currentPage.id),
|
||||||
|
{
|
||||||
|
id: state.currentPage.id,
|
||||||
|
title: state.currentPage.title,
|
||||||
|
queries: [...state.cards],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
this.localStorageService.set('savedPages', savedPages).subscribe(
|
||||||
|
// success
|
||||||
|
() => {
|
||||||
|
this.dispatch({
|
||||||
|
type: 'UPDATE_SAVED_PAGES',
|
||||||
|
savedPages,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// error
|
||||||
|
() => {
|
||||||
|
this.dispatch({
|
||||||
|
type: 'UPDATE_ERROR',
|
||||||
|
error: {
|
||||||
|
// tslint:disable-next-line: quotemark
|
||||||
|
msg: "Something went wrong and the page wasn't saved. :(",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Display Settings
|
//#region Display Settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user