unsubscribe timeline on deletion

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-10-07 13:44:35 -04:00
parent 1bf9d5d934
commit 0d994172a0
2 changed files with 20 additions and 0 deletions

View File

@@ -149,6 +149,11 @@ impl Columns {
.1
}
pub fn find_timeline_for_column_index(&self, ind: usize) -> Option<&Timeline> {
let col_id = self.get_column_id_at_index(ind);
self.timelines.get(&col_id)
}
pub fn select_down(&mut self) {
warn!("todo: implement select_down");
}

View File

@@ -18,6 +18,7 @@ use crate::{
use egui::{pos2, Color32, InnerResponse};
use egui_nav::{Nav, NavAction};
use tracing::{error, info};
pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
let col_id = app.columns.get_column_id_at_index(col);
@@ -149,6 +150,20 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
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 {
if let Some(sub_id) = timeline.subscription {
if let Err(e) = app.ndb.unsubscribe(sub_id) {
error!("unsubscribe error: {}", e);
} else {
info!(
"successfully unsubscribed from timeline {} with sub id {}",
timeline.id,
sub_id.id()
);
}
}
}
}
}
}