23
src/nav.rs
23
src/nav.rs
@@ -7,7 +7,7 @@ use crate::{
|
|||||||
thread::thread_unsubscribe,
|
thread::thread_unsubscribe,
|
||||||
timeline::{
|
timeline::{
|
||||||
route::{render_profile_route, render_timeline_route, AfterRouteExecution, TimelineRoute},
|
route::{render_profile_route, render_timeline_route, AfterRouteExecution, TimelineRoute},
|
||||||
PubkeySource, TimelineKind,
|
PubkeySource, Timeline, TimelineKind,
|
||||||
},
|
},
|
||||||
ui::{
|
ui::{
|
||||||
self,
|
self,
|
||||||
@@ -21,6 +21,7 @@ use crate::{
|
|||||||
|
|
||||||
use egui::{pos2, Color32, InnerResponse, Stroke};
|
use egui::{pos2, Color32, InnerResponse, Stroke};
|
||||||
use egui_nav::{Nav, NavAction, TitleBarResponse};
|
use egui_nav::{Nav, NavAction, TitleBarResponse};
|
||||||
|
use nostrdb::Ndb;
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
||||||
@@ -170,6 +171,12 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
|||||||
id.bytes(),
|
id.bytes(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(Route::Profile(_, id)) = r {
|
||||||
|
if let Some(timeline) = app.columns.find_timeline(id) {
|
||||||
|
unsubscribe_timeline(&app.ndb, timeline);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if let Some(NavAction::Navigated) = nav_response.action {
|
} else if let Some(NavAction::Navigated) = nav_response.action {
|
||||||
let cur_router = app.columns_mut().column_mut(col).router_mut();
|
let cur_router = app.columns_mut().column_mut(col).router_mut();
|
||||||
cur_router.navigating = false;
|
cur_router.navigating = false;
|
||||||
@@ -184,8 +191,16 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
|||||||
app.columns_mut().request_deletion_at_index(col);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unsubscribe_timeline(ndb: &Ndb, timeline: &Timeline) {
|
||||||
if let Some(sub_id) = timeline.subscription {
|
if let Some(sub_id) = timeline.subscription {
|
||||||
if let Err(e) = app.ndb.unsubscribe(sub_id) {
|
if let Err(e) = ndb.unsubscribe(sub_id) {
|
||||||
error!("unsubscribe error: {}", e);
|
error!("unsubscribe error: {}", e);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
@@ -195,10 +210,6 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn title_bar(
|
fn title_bar(
|
||||||
|
|||||||
Reference in New Issue
Block a user