Commit 5915f3b 1 parent f6ae4b9 commit 5915f3b Copy full SHA for 5915f3b
File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,7 @@ fn spawn_receiver_tasks(app_handle: &AppHandle) {
210
210
tauri:: async_runtime:: spawn ( async move {
211
211
let state: tauri:: State < ' _ , AppState > = capp_handle. state ( ) ;
212
212
let mut ble_receiver = state. ble_receiver . resubscribe ( ) ;
213
+ let mut last_sent = std:: time:: Instant :: now ( ) - std:: time:: Duration :: from_secs ( 120 ) ;
213
214
214
215
loop {
215
216
let rinfo = ble_receiver. recv ( ) . await ;
@@ -219,9 +220,12 @@ fn spawn_receiver_tasks(app_handle: &AppHandle) {
219
220
let v = get_visibility ( & capp_handle) ;
220
221
trace ! ( "Tauri: ble received: {:?}" , v) ;
221
222
222
- if v == Visibility :: Invisible {
223
+ if v == Visibility :: Invisible
224
+ && last_sent. elapsed ( ) >= std:: time:: Duration :: from_secs ( 120 )
225
+ {
223
226
#[ cfg( not( target_os = "macos" ) ) ]
224
227
send_temporarily_notification ( & capp_handle) ;
228
+ last_sent = std:: time:: Instant :: now ( ) ;
225
229
}
226
230
}
227
231
Err ( e) => {
Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ fn spawn_receiver_tasks(app_handle: &AppHandle) {
243
243
tauri:: async_runtime:: spawn ( async move {
244
244
let state: tauri:: State < ' _ , AppState > = capp_handle. state ( ) ;
245
245
let mut ble_receiver = state. ble_receiver . resubscribe ( ) ;
246
+ let mut last_sent = std:: time:: Instant :: now ( ) - std:: time:: Duration :: from_secs ( 120 ) ;
246
247
247
248
loop {
248
249
let rinfo = ble_receiver. recv ( ) . await ;
@@ -252,8 +253,11 @@ fn spawn_receiver_tasks(app_handle: &AppHandle) {
252
253
let v = get_visibility ( & capp_handle) ;
253
254
trace ! ( "Tauri: ble received: {:?}" , v) ;
254
255
255
- if v == Visibility :: Invisible {
256
+ if v == Visibility :: Invisible
257
+ && last_sent. elapsed ( ) >= std:: time:: Duration :: from_secs ( 120 )
258
+ {
256
259
send_temporarily_notification ( & capp_handle) ;
260
+ last_sent = std:: time:: Instant :: now ( ) ;
257
261
}
258
262
}
259
263
Err ( e) => {
You can’t perform that action at this time.
0 commit comments