From 22f8031b918930d364e4cce3cff262510962cc60 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sun, 3 May 2026 16:02:14 -0400 Subject: [PATCH] Fix bug where home screen editor is empty with a fresh install --- CHANGELOG.md | 4 ++- .../HomeScreenEditor/HomeScreenEditor.bs | 29 +++++++++++++++---- .../Services/Preferences/Preferences.bs | 4 ++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6cbbb24..3a2e4c57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Fixed + +- Bug where home screen editor is empty with a fresh install ## [0.44.9] - 2026-04-25 diff --git a/playlet-lib/src/components/Screens/SettingsScreen/HomeScreenEditor/HomeScreenEditor.bs b/playlet-lib/src/components/Screens/SettingsScreen/HomeScreenEditor/HomeScreenEditor.bs index 6616e8fd..5fc4be28 100644 --- a/playlet-lib/src/components/Screens/SettingsScreen/HomeScreenEditor/HomeScreenEditor.bs +++ b/playlet-lib/src/components/Screens/SettingsScreen/HomeScreenEditor/HomeScreenEditor.bs @@ -7,10 +7,10 @@ import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/Types.bs" function Init() - m.homeLayout = {} - homeLayout = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/default_home_layout.yaml")) - for each item in homeLayout - m.homeLayout[item.id] = item + m.homeLayoutMap = {} + homeLayoutMap = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/default_home_layout.yaml")) + for each item in homeLayoutMap + m.homeLayoutMap[item.id] = item end for m.checkList = m.top.findNode("checkList") @@ -81,17 +81,34 @@ function OnValueChange() nodes = [] checkedState = [] + homeLayoutMap = {} + homeLayoutMap.Append(m.homeLayoutMap) + for each item in value - feed = m.homeLayout[item.id] + feed = homeLayoutMap[item.id] if feed = invalid LogWarn("unknown feed id:", item.id) continue for end if + homeLayoutMap.Delete(item.id) + node = CreateObject("roSGNode", "ContentNode") + node.id = feed.id + node.title = Tr(feed.title) + nodes.push(node) + checkedState.push(item.enabled) + end for + + for each id in homeLayoutMap + feed = homeLayoutMap[id] + if feed = invalid + LogWarn("unknown feed id:", id) + continue for + end if node = CreateObject("roSGNode", "ContentNode") node.id = feed.id node.title = Tr(feed.title) nodes.push(node) - checkedState.push(item.enabled) + checkedState.push(false) end for labelCount = content.getChildCount() diff --git a/playlet-lib/src/components/Services/Preferences/Preferences.bs b/playlet-lib/src/components/Services/Preferences/Preferences.bs index 5306cb11..2953ba06 100644 --- a/playlet-lib/src/components/Services/Preferences/Preferences.bs +++ b/playlet-lib/src/components/Services/Preferences/Preferences.bs @@ -171,7 +171,9 @@ function MigrateExistingPreferences(userPrefs as object) as boolean end if filteredLayout.Push(item) end for - userPrefs["misc.home_screen_layout"] = filteredLayout + if filteredLayout.Count() > 0 + userPrefs["misc.home_screen_layout"] = filteredLayout + end if userPrefs.__version = 6 isDirty = true end if