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

Skip to content

Commit f5a13af

Browse files
authored
Merge pull request sngxpro#47 from liby/master
[Running Mode] 修复了通知节流没有起作用的 Bug
2 parents e61f2d7 + c3ec19c commit f5a13af

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Tools/RunningMode/running-mode.js

Lines changed: 6 additions & 9 deletions
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)