From 3287888a5c4413c4d5aae18f2c5258649ec99399 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 21 Jul 2019 09:24:11 -0400 Subject: [PATCH] JSON configs read(): Merge default and user data --- src/python/config_files.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/python/config_files.py b/src/python/config_files.py index 3eab57bc..76ba650e 100644 --- a/src/python/config_files.py +++ b/src/python/config_files.py @@ -38,9 +38,11 @@ class JSONConfigFile(ConfigFile): async def read(self) -> JsonData: try: - return json.loads(self.path.read_text()) + data = json.loads(self.path.read_text()) except (json.JSONDecodeError, FileNotFoundError): - return await self.default_data() + data = {} + + return {**await self.default_data(), **data} async def write(self, data: JsonData) -> None: @@ -99,6 +101,8 @@ class UIState(JSONConfigFile): async def default_data(self) -> JsonData: return { + "collapseAccounts": {}, + "collapseCategories": {}, "page": "Pages/Default.qml", "pageProperties": {}, "sidePaneManualWidth": None,