Merge pull request #73 from mlynch/fix/list-items-reset
Fixing list items state persistence
This commit is contained in:
+9
-3
@@ -28,11 +28,17 @@ export const setDone = (
|
|||||||
) => {
|
) => {
|
||||||
Store.update((s, o) => {
|
Store.update((s, o) => {
|
||||||
const listIndex = o.lists.findIndex(l => l === list);
|
const listIndex = o.lists.findIndex(l => l === list);
|
||||||
|
if (listIndex === -1) return;
|
||||||
|
|
||||||
const items = o.lists[listIndex].items;
|
const items = o.lists[listIndex].items;
|
||||||
const itemIndex = items?.findIndex(i => i === listItem);
|
const itemIndex = items?.findIndex(i => i === listItem);
|
||||||
const item = items?.[itemIndex ?? -1];
|
if (itemIndex === undefined || itemIndex < 0) return;
|
||||||
if (!item) return;
|
|
||||||
item.done = done;
|
const draftItem = s.lists[listIndex].items?.[itemIndex];
|
||||||
|
if (!draftItem) return;
|
||||||
|
|
||||||
|
draftItem.done = done;
|
||||||
|
|
||||||
if (list === o.selectedList) {
|
if (list === o.selectedList) {
|
||||||
s.selectedList = s.lists[listIndex];
|
s.selectedList = s.lists[listIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user