Skip to content

Commit

Permalink
fix: save columns on removal
Browse files Browse the repository at this point in the history
Fixes: #432
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Nov 13, 2024
1 parent 91016fa commit cfb65af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 7 additions & 15 deletions src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit cfb65af

Please sign in to comment.