@@ -14,7 +14,6 @@ use crate::app::{self, DeferredAction};
1414use crate :: fetch:: Uri ;
1515use crate :: start:: handle_notification;
1616use crate :: util:: Doc ;
17- use hatmil:: { Page , html} ;
1817use js_sys:: JsString ;
1918use resources:: Res ;
2019use std:: cell:: RefCell ;
@@ -33,8 +32,8 @@ pub enum NotifyState {
3332 Connecting ,
3433 /// Updating after event receipt
3534 Updating ,
36- /// Good / connected
37- Good ,
35+ /// Connected to SSE server
36+ Connected ,
3837}
3938
4039impl NotifyState {
@@ -45,30 +44,9 @@ impl NotifyState {
4544 Self :: Disconnected => "⚫" ,
4645 Self :: Connecting => "🟠" ,
4746 Self :: Updating => "🟡" ,
48- Self :: Good => "🟢" ,
47+ Self :: Connected => "🟢" ,
4948 }
5049 }
51-
52- /// Get description of a state
53- pub const fn description ( self ) -> & ' static str {
54- match self {
55- Self :: Starting => "Starting" ,
56- Self :: Disconnected => "Disconnected" ,
57- Self :: Connecting => "Connecting" ,
58- Self :: Updating => "Updating" ,
59- Self :: Good => "Good" ,
60- }
61- }
62-
63- /// Build state HTML
64- pub fn build_html ( self ) -> String {
65- let mut page = Page :: new ( ) ;
66- let mut div = page. frag :: < html:: Div > ( ) ;
67- div. class ( "tooltip" ) . cdata ( self . symbol ( ) ) ;
68- div. span ( ) . class ( "right" ) . cdata ( self . description ( ) ) . close ( ) ;
69- div. cdata ( " " ) ;
70- String :: from ( page)
71- }
7250}
7351
7452/// SSE event listener
@@ -178,7 +156,7 @@ fn build_list(res: Option<Res>) -> String {
178156/// Set refresh button text
179157pub fn set_notify_state ( ns : NotifyState ) {
180158 let sb_notify = Doc :: get ( ) . elem :: < HtmlElement > ( "sb_notify" ) ;
181- sb_notify. set_inner_html ( & ns. build_html ( ) ) ;
159+ sb_notify. set_inner_html ( & ns. symbol ( ) ) ;
182160 if NotifyState :: Disconnected == ns {
183161 app:: defer_action ( DeferredAction :: MakeEventSource , 5000 ) ;
184162 }
@@ -194,5 +172,8 @@ fn handle_notify(payload: JsString) {
194172 let name = chan. find ( '$' ) . map ( |i| chan. split_off ( i) ) ;
195173 handle_notification ( chan, name) ;
196174 }
197- app:: defer_action ( DeferredAction :: SetNotifyState ( NotifyState :: Good ) , 600 ) ;
175+ app:: defer_action (
176+ DeferredAction :: SetNotifyState ( NotifyState :: Connected ) ,
177+ 600 ,
178+ ) ;
198179}
0 commit comments