notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 08a720b860f36396a1e721e960fe2c9d7823e004
parent 99aa50c120d37d3fc68c1e5091511cab20ab8dd5
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 22 May 2025 18:51:10 -0400

add `SingletonRouter`

used for popup

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck_columns/src/route.rs | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck_columns/src/route.rs b/crates/notedeck_columns/src/route.rs @@ -361,3 +361,40 @@ impl fmt::Display for Route { } } } + +#[derive(Clone, Debug)] +pub struct SingletonRouter<R: Clone> { + route: Option<R>, + pub returning: bool, + pub navigating: bool, +} + +impl<R: Clone> SingletonRouter<R> { + pub fn route_to(&mut self, route: R) { + self.navigating = true; + self.route = Some(route); + } + + pub fn go_back(&mut self) { + self.returning = true; + } + + pub fn clear(&mut self) { + self.route = None; + self.returning = false; + } + + pub fn route(&self) -> &Option<R> { + &self.route + } +} + +impl<R: Clone> Default for SingletonRouter<R> { + fn default() -> Self { + Self { + route: None, + returning: false, + navigating: false, + } + } +}