@@ -153,55 +153,60 @@ impl Notification {
153153 deprecated = "This function does not work on Windows 7. Use `Self::notify` instead."
154154 ) ]
155155 pub fn show ( self ) -> crate :: api:: Result < ( ) > {
156- let mut notification = notify_rust:: Notification :: new ( ) ;
157- if let Some ( body) = self . body {
158- notification. body ( & body) ;
159- }
160- if let Some ( title) = self . title {
161- notification. summary ( & title) ;
162- }
163- if let Some ( icon) = self . icon {
164- notification. icon ( & icon) ;
165- } else {
166- notification. auto_icon ( ) ;
167- }
168- if let Some ( sound) = self . sound {
169- notification. sound_name ( & match sound {
170- #[ cfg( target_os = "macos" ) ]
171- Sound :: Default => "NSUserNotificationDefaultSoundName" . to_string ( ) ,
172- #[ cfg( windows) ]
173- Sound :: Default => "Default" . to_string ( ) ,
174- #[ cfg( all( unix, not( target_os = "macos" ) ) ) ]
175- Sound :: Default => "message-new-instant" . to_string ( ) ,
176- Sound :: Custom ( c) => c,
177- } ) ;
178- }
179- #[ cfg( windows) ]
156+ #[ cfg( feature = "dox" ) ]
157+ return Ok ( ( ) ) ;
158+ #[ cfg( not( feature = "dox" ) ) ]
180159 {
181- let exe = tauri_utils:: platform:: current_exe ( ) ?;
182- let exe_dir = exe. parent ( ) . expect ( "failed to get exe directory" ) ;
183- let curr_dir = exe_dir. display ( ) . to_string ( ) ;
184- // set the notification's System.AppUserModel.ID only when running the installed app
185- if !( curr_dir. ends_with ( format ! ( "{SEP}target{SEP}debug" ) . as_str ( ) )
186- || curr_dir. ends_with ( format ! ( "{SEP}target{SEP}release" ) . as_str ( ) ) )
187- {
188- notification. app_id ( & self . identifier ) ;
160+ let mut notification = notify_rust:: Notification :: new ( ) ;
161+ if let Some ( body) = self . body {
162+ notification. body ( & body) ;
189163 }
190- }
191- # [ cfg ( target_os = "macos" ) ]
192- {
193- let _ = notify_rust :: set_application ( if cfg ! ( feature = "custom-protocol" ) {
194- & self . identifier
164+ if let Some ( title ) = self . title {
165+ notification . summary ( & title ) ;
166+ }
167+ if let Some ( icon ) = self . icon {
168+ notification . icon ( & icon ) ;
195169 } else {
196- "com.apple.Terminal"
197- } ) ;
198- }
170+ notification. auto_icon ( ) ;
171+ }
172+ if let Some ( sound) = self . sound {
173+ notification. sound_name ( & match sound {
174+ #[ cfg( target_os = "macos" ) ]
175+ Sound :: Default => "NSUserNotificationDefaultSoundName" . to_string ( ) ,
176+ #[ cfg( windows) ]
177+ Sound :: Default => "Default" . to_string ( ) ,
178+ #[ cfg( all( unix, not( target_os = "macos" ) ) ) ]
179+ Sound :: Default => "message-new-instant" . to_string ( ) ,
180+ Sound :: Custom ( c) => c,
181+ } ) ;
182+ }
183+ #[ cfg( windows) ]
184+ {
185+ let exe = tauri_utils:: platform:: current_exe ( ) ?;
186+ let exe_dir = exe. parent ( ) . expect ( "failed to get exe directory" ) ;
187+ let curr_dir = exe_dir. display ( ) . to_string ( ) ;
188+ // set the notification's System.AppUserModel.ID only when running the installed app
189+ if !( curr_dir. ends_with ( format ! ( "{SEP}target{SEP}debug" ) . as_str ( ) )
190+ || curr_dir. ends_with ( format ! ( "{SEP}target{SEP}release" ) . as_str ( ) ) )
191+ {
192+ notification. app_id ( & self . identifier ) ;
193+ }
194+ }
195+ #[ cfg( target_os = "macos" ) ]
196+ {
197+ let _ = notify_rust:: set_application ( if cfg ! ( feature = "custom-protocol" ) {
198+ & self . identifier
199+ } else {
200+ "com.apple.Terminal"
201+ } ) ;
202+ }
199203
200- crate :: async_runtime:: spawn ( async move {
201- let _ = notification. show ( ) ;
202- } ) ;
204+ crate :: async_runtime:: spawn ( async move {
205+ let _ = notification. show ( ) ;
206+ } ) ;
203207
204- Ok ( ( ) )
208+ Ok ( ( ) )
209+ }
205210 }
206211
207212 /// Shows the notification. This API is similar to [`Self::show`], but it also works on Windows 7.
0 commit comments