File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,15 @@ impl Message {
7575 title_text
7676 } )
7777 }
78+ pub fn notification_title ( & self , subscription : & Subscription ) -> String {
79+ self . display_title ( )
80+ . or ( if subscription. display_name . is_empty ( ) {
81+ None
82+ } else {
83+ Some ( subscription. display_name . to_string ( ) )
84+ } )
85+ . unwrap_or ( self . topic . to_string ( ) )
86+ }
7887
7988 pub fn display_message ( & self ) -> Option < String > {
8089 self . message . as_ref ( ) . map ( |message| {
Original file line number Diff line number Diff line change @@ -86,23 +86,21 @@ impl output_channel::Server for NotifyForwarder {
8686 let msg: Message = pry ! ( serde_json:: from_str( & message)
8787 . map_err( |e| Error :: InvalidMessage ( message. to_string( ) , e) ) ) ;
8888 let np = self . env . proxy . clone ( ) ;
89- tokio:: task:: spawn_local ( async move {
90- let title = msg. display_title ( ) ;
91- let title = title. as_ref ( ) . map ( |x| x. as_str ( ) ) . unwrap_or ( & msg. topic ) ;
92-
93- let n = models:: Notification {
94- title : title. to_string ( ) ,
95- body : msg
96- . display_message ( )
97- . as_ref ( )
98- . map ( |x| x. as_str ( ) )
99- . unwrap_or ( "" )
100- . to_string ( ) ,
101- } ;
102-
103- info ! ( "Showing notification" ) ;
104- np. send ( n) . unwrap ( ) ;
105- } ) ;
89+
90+ let title = { msg. notification_title ( & * self . model . borrow ( ) ) } ;
91+
92+ let n = models:: Notification {
93+ title : title. to_string ( ) ,
94+ body : msg
95+ . display_message ( )
96+ . as_ref ( )
97+ . map ( |x| x. as_str ( ) )
98+ . unwrap_or ( "" )
99+ . to_string ( ) ,
100+ } ;
101+
102+ info ! ( "Showing notification" ) ;
103+ np. send ( n) . unwrap ( ) ;
106104 }
107105
108106 // Forward
You can’t perform that action at this time.
0 commit comments