commit 4c458727a93d28a339f74ab9d8c57d859b01b096
parent 91016facc720a3eb2b65f907fbcc7eb0f3ff4163
Author: William Casarin <jb55@jb55.com>
Date: Wed, 13 Nov 2024 15:46:39 -0800
fix: save columns on removal
Fixes: https://github.com/damus-io/notedeck/issues/432
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
3 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/src/app.rs b/src/app.rs
@@ -513,8 +513,6 @@ fn update_damus(damus: &mut Damus, ctx: &egui::Context) {
}
damus.app_rect_handler.try_save_app_size(ctx);
-
- damus.columns.attempt_perform_deletion_request();
}
fn process_event(damus: &mut Damus, _subid: &str, event: &str) {
diff --git a/src/column.rs b/src/column.rs
@@ -61,7 +61,6 @@ pub struct Columns {
/// The selected column for key navigation
selected: i32,
- should_delete_column_at_index: Option<usize>,
}
static UIDS: AtomicU32 = AtomicU32::new(0);
@@ -207,22 +206,15 @@ impl Columns {
self.selected += 1;
}
- pub fn request_deletion_at_index(&mut self, index: usize) {
- self.should_delete_column_at_index = Some(index);
- }
-
- pub fn attempt_perform_deletion_request(&mut self) {
- if let Some(index) = self.should_delete_column_at_index {
- if let Some((key, _)) = self.columns.get_index_mut(index) {
- self.timelines.shift_remove(key);
- }
+ pub fn delete_column(&mut self, index: usize) {
+ if let Some((key, _)) = self.columns.get_index_mut(index) {
+ self.timelines.shift_remove(key);
+ }
- self.columns.shift_remove_index(index);
- self.should_delete_column_at_index = None;
+ self.columns.shift_remove_index(index);
- if self.columns.is_empty() {
- self.new_column_picker();
- }
+ if self.columns.is_empty() {
+ self.new_column_picker();
}
}
diff --git a/src/nav.rs b/src/nav.rs
@@ -205,11 +205,12 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) -> bool {
if let Some(title_response) = nav_response.title_response {
match title_response {
TitleResponse::RemoveColumn => {
- app.columns_mut().request_deletion_at_index(col);
let tl = app.columns().find_timeline_for_column_index(col);
if let Some(timeline) = tl {
unsubscribe_timeline(app.ndb(), timeline);
}
+ app.columns_mut().delete_column(col);
+ col_changed = true;
}
}
}