fix: save columns on removal
Fixes: https://github.com/damus-io/notedeck/issues/432 Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -513,8 +513,6 @@ fn update_damus(damus: &mut Damus, ctx: &egui::Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
damus.app_rect_handler.try_save_app_size(ctx);
|
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) {
|
fn process_event(damus: &mut Damus, _subid: &str, event: &str) {
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ pub struct Columns {
|
|||||||
|
|
||||||
/// The selected column for key navigation
|
/// The selected column for key navigation
|
||||||
selected: i32,
|
selected: i32,
|
||||||
should_delete_column_at_index: Option<usize>,
|
|
||||||
}
|
}
|
||||||
static UIDS: AtomicU32 = AtomicU32::new(0);
|
static UIDS: AtomicU32 = AtomicU32::new(0);
|
||||||
|
|
||||||
@@ -207,22 +206,15 @@ impl Columns {
|
|||||||
self.selected += 1;
|
self.selected += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_deletion_at_index(&mut self, index: usize) {
|
pub fn delete_column(&mut self, index: usize) {
|
||||||
self.should_delete_column_at_index = Some(index);
|
if let Some((key, _)) = self.columns.get_index_mut(index) {
|
||||||
}
|
self.timelines.shift_remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn attempt_perform_deletion_request(&mut self) {
|
self.columns.shift_remove_index(index);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.columns.shift_remove_index(index);
|
if self.columns.is_empty() {
|
||||||
self.should_delete_column_at_index = None;
|
self.new_column_picker();
|
||||||
|
|
||||||
if self.columns.is_empty() {
|
|
||||||
self.new_column_picker();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
if let Some(title_response) = nav_response.title_response {
|
||||||
match title_response {
|
match title_response {
|
||||||
TitleResponse::RemoveColumn => {
|
TitleResponse::RemoveColumn => {
|
||||||
app.columns_mut().request_deletion_at_index(col);
|
|
||||||
let tl = app.columns().find_timeline_for_column_index(col);
|
let tl = app.columns().find_timeline_for_column_index(col);
|
||||||
if let Some(timeline) = tl {
|
if let Some(timeline) = tl {
|
||||||
unsubscribe_timeline(app.ndb(), timeline);
|
unsubscribe_timeline(app.ndb(), timeline);
|
||||||
}
|
}
|
||||||
|
app.columns_mut().delete_column(col);
|
||||||
|
col_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user