clock-digital12 and clock-digital had become the same module (same lib/clock code, same right-click settings), differing only in the starting format. Keep one: the Digital Clock now starts in 12-hour mode with AM/PM, and its "Time format" setting switches to 24-hour. - components/clock-digital12 is gone (and from scripts/components.txt); lib/clock drops digital12_info/digital12_config. - The default panel loads clock-digital. - "clock-digital12" stays an alias (find_module, slot_of, saved panels) and is never listed in the module picker, even if an old .wasm is still installed. - panel.edn gets :version 2. A version-1 panel is migrated once: the old 12-hour clock becomes the Digital Clock with its settings (state.edn :module-config) moved over in 12-hour mode; a panel that had the old 24-hour Digital Clock keeps 24-hour. The file is rewritten afterwards. - Tests updated, plus a migration test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgnZsS91fwCreut8FL
This commit is contained in:
25 files changed
+207
-925
No files matched your search
@@ -87,6 +87,11 @@ fn DesktopShell::remember_module_setting(self : DesktopShell, id : String, key :
|
||||
self.module_cfg.set(id, m)
|
||||
}
|
||||
}
|
||||
self.write_module_cfg()
|
||||
}
|
||||
|
||||
///| Write `:module-config` to state.edn, keeping every other key (a no-op without `persist`).
|
||||
fn DesktopShell::write_module_cfg(self : DesktopShell) -> Unit {
|
||||
if !self.persist {
|
||||
return
|
||||
}
|
||||
@@ -107,6 +112,35 @@ fn DesktopShell::remember_module_setting(self : DesktopShell, id : String, key :
|
||||
write_state_file(entries)
|
||||
}
|
||||
|
||||
///| A panel saved before the 12-hour clock (clock-digital12) became part of the Digital Clock
|
||||
/// (panel.edn version 1, `saved` its module list as written): keep each clock as it was. The
|
||||
/// 12-hour clock's settings become the Digital Clock's, starting from 12-hour mode; a panel that
|
||||
/// had only the Digital Clock keeps it in 24-hour mode (its old default) unless a format was chosen.
|
||||
/// A panel with both now has two Digital Clocks sharing the Digital Clock's settings.
|
||||
fn DesktopShell::migrate_module_cfg(self : DesktopShell, saved : Array[String]) -> Unit {
|
||||
self.read_module_cfg()
|
||||
let had12 = saved.contains("clock-digital12")
|
||||
let had24 = saved.contains("clock-digital")
|
||||
let old12 = self.module_cfg.get("clock-digital12")
|
||||
if had12 && !had24 {
|
||||
let m : Map[String, String] = { "format": "12-hour" }
|
||||
match old12 {
|
||||
Some(o) => for k, v in o { m.set(k, v) }
|
||||
None => ()
|
||||
}
|
||||
self.module_cfg.set("clock-digital", m)
|
||||
} else if had24 && !had12 {
|
||||
match self.module_cfg.get("clock-digital") {
|
||||
Some(m) => if !m.contains("format") { m.set("format", "24-hour") }
|
||||
None => self.module_cfg.set("clock-digital", { "format": "24-hour" })
|
||||
}
|
||||
}
|
||||
if (had12 && !had24) || (had24 && !had12) || old12 is Some(_) {
|
||||
self.module_cfg.remove("clock-digital12")
|
||||
self.write_module_cfg()
|
||||
}
|
||||
}
|
||||
|
||||
///| The setting `key` of module `id` as last chosen, if any.
|
||||
pub fn DesktopShell::module_setting(self : DesktopShell, id : String, key : String) -> String? {
|
||||
self.read_module_cfg()
|
||||
|
||||
Reference in new issue
Block a user