mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-25 08:19:50 -04:00
Dont assume saved pages is not null in the state
This commit is contained in:
parent
0231742800
commit
0aeb891b32
@ -13,7 +13,7 @@ import { CardItem } from '../../models/card-state';
|
|||||||
export class AddToPageModalComponent {
|
export class AddToPageModalComponent {
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
title: string;
|
title: string;
|
||||||
pages$ = this.appService.select((state) => state.savedPages);
|
pages$ = this.appService.select((state) => (state.savedPages === null ? null : state.savedPages.value));
|
||||||
|
|
||||||
@ViewChild('pageList')
|
@ViewChild('pageList')
|
||||||
pageList: MatSelectionList;
|
pageList: MatSelectionList;
|
||||||
|
@ -178,7 +178,7 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
|||||||
}
|
}
|
||||||
case 'SAVE_PAGE': {
|
case 'SAVE_PAGE': {
|
||||||
const savedPages = new Storable([
|
const savedPages = new Storable([
|
||||||
...state.savedPages.value,
|
...(state.savedPages ? state.savedPages.value : []),
|
||||||
{
|
{
|
||||||
// create a new saved page object
|
// create a new saved page object
|
||||||
title: action.title,
|
title: action.title,
|
||||||
@ -216,7 +216,7 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
|||||||
}
|
}
|
||||||
case 'ADD_CARD_TO_SAVED_PAGE': {
|
case 'ADD_CARD_TO_SAVED_PAGE': {
|
||||||
const savedPages = new Storable([
|
const savedPages = new Storable([
|
||||||
...state.savedPages.value.map((o) => {
|
...(state.savedPages ? state.savedPages.value : []).map((o) => {
|
||||||
if (o.id.toString() === action.pageId) {
|
if (o.id.toString() === action.pageId) {
|
||||||
let cards = [] as CardItem[];
|
let cards = [] as CardItem[];
|
||||||
if (state.settings.value.displaySettings.appendCardToBottom) {
|
if (state.settings.value.displaySettings.appendCardToBottom) {
|
||||||
@ -294,7 +294,7 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
|||||||
const savedPages =
|
const savedPages =
|
||||||
state.currentSavedPage !== null
|
state.currentSavedPage !== null
|
||||||
? new Storable(
|
? new Storable(
|
||||||
state.savedPages.value.map((o) => {
|
(state.savedPages ? state.savedPages.value : []).map((o) => {
|
||||||
if (o === state.currentSavedPage) {
|
if (o === state.currentSavedPage) {
|
||||||
return currentSavedPage;
|
return currentSavedPage;
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const savedPages = new Storable<SavedPage[]>([
|
const savedPages = new Storable<SavedPage[]>([
|
||||||
...state.savedPages.value.map((sp) => {
|
...(state.savedPages ? state.savedPages.value : []).map((sp) => {
|
||||||
return {
|
return {
|
||||||
...sp,
|
...sp,
|
||||||
queries: sp.queries.map((o) => {
|
queries: sp.queries.map((o) => {
|
||||||
@ -457,7 +457,7 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
|||||||
const notes = new Storable<NoteItem[]>([...state.notes.value.filter((o) => o.id !== action.note.id)]);
|
const notes = new Storable<NoteItem[]>([...state.notes.value.filter((o) => o.id !== action.note.id)]);
|
||||||
|
|
||||||
const savedPages = new Storable<SavedPage[]>([
|
const savedPages = new Storable<SavedPage[]>([
|
||||||
...state.savedPages.value.map((sp) => {
|
...(state.savedPages ? state.savedPages.value : []).map((sp) => {
|
||||||
return {
|
return {
|
||||||
...sp,
|
...sp,
|
||||||
queries: sp.queries.filter((o) => {
|
queries: sp.queries.filter((o) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user