pKakidashi
Post 8 with Wifi off.
Wifi On
- It’s automatically stored in the cloud.
- The (local save ok) flag is gone at that time. ts
setGlobal({ items: [...global.items, item] });
local_db.items.add(item).then(() => {
const new_item = { ...item, saved_local: true }
setGlobal({ items: [...global.items, new_item] });
})
addItemToFirestore(item).then(() => {
const new_item = { ...item, saved_cloud: true }
setGlobal({ items: [...global.items, new_item] });
})
ts
const updateItem = (index: number, diff: { [key: string]: any }) => {
const global = getGlobal();
const new_item = { ...global.items[index], ...diff }
const new_items = [...global.items]
new_items[index] = new_item;
setGlobal({ items: new_items });
}
const index = global.items.length;
setGlobal({ items: [...global.items, item] });
local_db.items.add(item).then(() => {
updateItem(index, { saved_local: true })
})
addItemToFirestore(item).then(() => {
updateItem(index, { saved_cloud: true })
local_db.items.update(item.created, { saved_cloud: true })
})
- Reloaded without cloud save will not be retried.
- Immediately retry anything restored from local on reload
- under
This page is auto-translated from /nishio/2020-01-21 using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.