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.

This commit is contained in:
Jason Wall 2020-08-23 10:19:28 -04:00
parent e3c87cf660
commit fae6bac6cd

View File

@ -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<NoteItem[]>([...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;
}),
};
}),