Skip to content

Commit af55d31

Browse files
authored
Merge pull request #679 from multiplex55/codex/update-timers-widget-registration-and-config
Rename dashboard widget key `active_timers` → `timers` and add migration
2 parents cea19b9 + 5cf8cce commit af55d31

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/dashboard/config.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Default for DashboardConfig {
122122
SlotConfig::with_widget("recent_commands", 1, 0),
123123
SlotConfig::with_widget("frequent_commands", 1, 1),
124124
SlotConfig::with_widget("recent_notes", 1, 2),
125-
SlotConfig::with_widget("active_timers", 2, 0),
125+
SlotConfig::with_widget("timers", 2, 0),
126126
SlotConfig::with_widget("clipboard_snippets", 2, 1),
127127
],
128128
}
@@ -156,6 +156,7 @@ impl DashboardConfig {
156156
/// Remove unsupported widgets and normalize empty settings.
157157
pub fn sanitize(&mut self, registry: &WidgetRegistry) -> Vec<String> {
158158
let mut warnings = Vec::new();
159+
self.migrate_active_timers_widgets(registry, &mut warnings);
159160
self.migrate_todo_widgets(registry, &mut warnings);
160161
self.slots.retain(|slot| {
161162
if slot.widget.is_empty() {
@@ -207,4 +208,21 @@ impl DashboardConfig {
207208
}
208209
}
209210
}
211+
212+
fn migrate_active_timers_widgets(
213+
&mut self,
214+
registry: &WidgetRegistry,
215+
warnings: &mut Vec<String>,
216+
) {
217+
for slot in &mut self.slots {
218+
let Some(default_settings) = registry.default_settings("timers") else {
219+
continue;
220+
};
221+
if slot.widget == "active_timers" {
222+
slot.widget = "timers".into();
223+
slot.settings = merge_json(&default_settings, &slot.settings);
224+
warnings.push("dashboard widget 'active_timers' migrated to 'timers'".to_string());
225+
}
226+
}
227+
}
210228
}

src/dashboard/widgets/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl WidgetRegistry {
243243
WidgetFactory::new(QueryListWidget::new).with_settings_ui(QueryListWidget::settings_ui),
244244
);
245245
reg.register(
246-
"active_timers",
246+
"timers",
247247
WidgetFactory::new(ActiveTimersWidget::new)
248248
.with_settings_ui(ActiveTimersWidget::settings_ui),
249249
);

0 commit comments

Comments
 (0)