From fae6bac6cde474210f5520e3171d1f7d91f377bb Mon Sep 17 00:00:00 2001 From: Jason Wall Date: Sun, 23 Aug 2020 10:19:28 -0400 Subject: [PATCH] oops, no data in the current cards anymore. and, since you store the id in the qry, you don't need to remove get it from the card cache. --- src/src/app/services/app-state-reducer.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/src/app/services/app-state-reducer.ts b/src/src/app/services/app-state-reducer.ts index 951e8cc2..186cb6bd 100644 --- a/src/src/app/services/app-state-reducer.ts +++ b/src/src/app/services/app-state-reducer.ts @@ -308,6 +308,7 @@ export function reducer(state: AppState, action: AppAction): AppState { cardCache: removeFromCardCache(action.card, state.cardCache), }; } + case 'MOVE_CARD': { const cards = moveItemUpOrDown(state.currentCards, action.card, action.direction); @@ -438,14 +439,15 @@ export function reducer(state: AppState, action: AppAction): AppState { // so iterate through all of them and if you find the note // in any of them, remove it - const card = state.currentCards.find((o) => o.qry === `note: ${action.note.id}`); + const card = state.currentCards.find((o) => o.qry === action.note.id); - const cards = [ - ...state.currentCards.filter((o) => { - const n = getFromCardCache(o, state.cardCache); - return o.type !== CardType.Note || (n.data as NoteItem).id !== action.note.id; - }), - ]; + const cards = card + ? [ + ...state.currentCards.filter((o) => { + return o.type !== CardType.Note || o.qry !== action.note.id; + }), + ] + : state.currentCards; // if card is undefined, then it wasn't in the current card list. const notes = new Storable([...state.notes.value.filter((o) => o.id !== action.note.id)]); @@ -454,8 +456,7 @@ export function reducer(state: AppState, action: AppAction): AppState { return { ...sp, queries: sp.queries.filter((o) => { - const n = getFromCardCache(o, state.cardCache); - return o.type !== CardType.Note || (n.data as NoteItem).id !== action.note.id; + return o.type !== CardType.Note || o.qry !== action.note.id; }), }; }),