Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3ec19c

Browse files
committed
🐛 fix: rewrote the throttle feature to make sure it worked
1 parent e61f2d7 commit c3ec19c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Tools/RunningMode/running-mode.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,11 @@ function lookupSSID(ssid) {
100100
}
101101

102102
function notify(title, subtitle, content) {
103-
const TIMESTAMP_KEY = "running_mode_notified_time";
104-
const THROTTLE_TIME = 3 * 1000;
105-
const lastNotifiedTime = $persistentStore.read(THROTTLE_TIME);
106-
if (
107-
!lastNotifiedTime ||
108-
new Date().getTime() - lastNotifiedTime > THROTTLE_TIME
109-
) {
110-
$persistentStore.write(new Date().getTime().toString(), TIMESTAMP_KEY);
103+
const SUBTITLE_STORE_KEY = "running_mode_notified_subtitle";
104+
const lastNotifiedSubtitle = $persistentStore.read(SUBTITLE_STORE_KEY);
105+
106+
if (!lastNotifiedSubtitle || lastNotifiedSubtitle !== subtitle) {
107+
$persistentStore.write(subtitle.toString(), SUBTITLE_STORE_KEY);
111108
$notification.post(title, subtitle, content);
112109
}
113-
}
110+
}

0 commit comments

Comments
 (0)