From 2d37b7abd04f2e898b8ffe9d8363348b28ac2796 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 22 Aug 2021 12:37:54 +1000 Subject: [PATCH] Add hack to fix broken database on clear cache --- src/modals/SettingsModal.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/modals/SettingsModal.tsx b/src/modals/SettingsModal.tsx index 286017f..2cb157d 100644 --- a/src/modals/SettingsModal.tsx +++ b/src/modals/SettingsModal.tsx @@ -101,6 +101,24 @@ function SettingsModal({ isOpen, onRequestClose }: SettingsModalProps) { await database.table("assets").delete(asset.id); } } + + // TODO: Remove this when 1.11 comes out + // Hack to fix broken database upgrade + for (let state of states) { + if ((state as any).drawShapes) { + await database.table("states").update(state.mapId, { + drawShapes: undefined, + drawings: (state as any).drawShapes, + }); + } + + if ((state as any).fogShapes) { + await database.table("states").update(state.mapId, { + fogShapes: undefined, + fogs: (state as any).fogShapes, + }); + } + } } window.location.reload();