Skip to content

Commit f5c2bc9

Browse files
committed
support notif sound only play once etc
also optimize change lang dialog exp by support two langs at once
1 parent 91682d4 commit f5c2bc9

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@
209209
"when-rest-time-end": "When rest time end",
210210
"sound": "Volume of notify sound / Mute",
211211
"sound-tip": "Change the notify sound when a period of time ends, or simply mute it.",
212+
"sound-play-once": "Play sound only once",
213+
"sound-play-once-tip": "When enabled, all notification sounds will play only once instead of looping.",
212214
"onemintip": "Notify when less than 1 min left",
213215
"onemintip-tip": "When a period of time will end in a minute we will send you a notification, so that you can pause your work comfortably.",
214216
"nap-in-timing": "Nap setting",

locales/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
"task-reservation-follow-plan": "依照预设:",
239239
"task-reservation-start-tip": "开始预设,从",
240240
"to": "",
241-
"when-time-end": "一段工作或休息结束时发出提醒",
241+
"when-time-end": "一段工作或休息结束时发出提醒种类",
242242
"when-time-end-tip": "调整在工作或休息后发出怎样的提醒。",
243243
"when-work-or-rest-end-tip": "若选择“确认框”则将在确认之前不会开启下一段时间;若选择“仅铃声”则将自动开始下一段时间,但 wnr 窗口仍会弹出到页面最前端;若选择“通知且不弹出”,则将只收到一条通知,而 wnr 窗口将不会重新跳出。",
244244
"dropdown-notification-no-popup": "通知且不弹出",
@@ -248,6 +248,8 @@
248248
"when-rest-time-end": "休息时间结束后",
249249
"sound": "调节提示音音量或静音",
250250
"sound-tip": "选择在一段时间结束后是否静音,或发出哪一档的声音。",
251+
"sound-play-once": "提示音仅播放一次",
252+
"sound-play-once-tip": "开启后,所有提示音将只播放一次,不再循环播放。",
251253
"onemintip": "还剩一分钟时发出提示",
252254
"onemintip-tip": "在每段时间还剩 1 分钟时发出提示,提醒你暂时收尾这段工作。",
253255
"nap-in-timing": "计时中途提醒(小憩设置)",

locales/zh-TW.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
"task-reservation-follow-plan": "依照預設:",
232232
"task-reservation-start-tip": "開始預設,從",
233233
"to": "",
234-
"when-time-end": "一段工作或休息結束時發出提醒",
234+
"when-time-end": "一段工作或休息結束時發出提醒種類",
235235
"when-time-end-tip": "調整在工作或休息後發出怎樣的提醒。",
236236
"when-work-or-rest-end-tip": "若選擇“確認框”則將在確認之前不會開啓下一段時間;若選擇“僅鈴聲”則將自動開始下一段時間,但 wnr 窗口仍會彈出到頁面最前端;若選擇“通知且不彈出”,則將只收到一條通知,而 wnr 窗口將不會重新跳出。",
237237
"dropdown-notification-no-popup": "通知且不彈出",
@@ -241,6 +241,8 @@
241241
"when-rest-time-end": "休息時間結束後",
242242
"sound": "調節提示音音量或靜音",
243243
"sound-tip": "選擇在一段時間結束後是否靜音,或發出哪一檔的聲音。",
244+
"sound-play-once": "提示音僅播放一次",
245+
"sound-play-once-tip": "開啟後,所有提示音將只播放一次,不再循環播放。",
244246
"onemintip": "還剩一分鐘時發出提示",
245247
"onemintip-tip": "在每段時間還剩 1 分鐘時發出提示,提醒你暫時收尾這段工作。",
246248
"nap-in-timing": "計時中途提醒(小憩設置)",

main.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,32 @@ ipcMain.on('locker-passcode', function (event, message) {
22112211
})
22122212

22132213
ipcMain.on("relaunch-dialog", function (event, message) {
2214-
customDialog("on", "wnr", i18n.__("relaunch-tip"),
2214+
let previousLang = store.get("previous-language");
2215+
let currentLang = store.get("i18n");
2216+
let messageText = i18n.__("relaunch-tip");
2217+
2218+
if (previousLang && previousLang !== currentLang) {
2219+
try {
2220+
const fs = require('fs');
2221+
let previousLangFile = path.join(__dirname, 'locales', previousLang + '.json');
2222+
let currentLangFile = path.join(__dirname, 'locales', currentLang + '.json');
2223+
2224+
if (fs.existsSync(previousLangFile) && fs.existsSync(currentLangFile)) {
2225+
let previousLangData = JSON.parse(fs.readFileSync(previousLangFile, 'utf8'));
2226+
let currentLangData = JSON.parse(fs.readFileSync(currentLangFile, 'utf8'));
2227+
2228+
let previousText = previousLangData["relaunch-tip"] || i18n.__("relaunch-tip");
2229+
let currentText = currentLangData["relaunch-tip"] || i18n.__("relaunch-tip");
2230+
2231+
messageText = previousText + "\n" + currentText;
2232+
}
2233+
} catch (e) {
2234+
console.log(e);
2235+
}
2236+
store.delete("previous-language");
2237+
}
2238+
2239+
customDialog("on", "wnr", messageText,
22152240
"try { store.set('just-relaunched', true); }" +
22162241
"catch (e) { console.log(e); }\n" +
22172242
"relaunchSolution();");

preferences-items.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ if (store.get("islocked") !== true) {
146146
choices: ['no-sound', 'very-low', 'low', 'medium', 'high', 'very-high', 'extreme'],
147147
def: 3,
148148
after: soundAfter
149+
}, {
150+
type: "selection",
151+
id: "sound-play-once"
149152
}, {
150153
type: "collapse",
151154
id: "personalization-notify-sound",

preferences-renderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ function languageInitializer() {
928928

929929
function languageSetting(val) {
930930
if (store.get('i18n') !== val) {
931+
store.set("previous-language", store.get('i18n'));
931932
store.set("i18n", val);
932933
}
933934
ipc.send("relaunch-dialog");

timer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ <h3>
869869
else
870870
player.src = store.get("custom-all-time-end-sound");
871871
}
872-
player.loop = true;
872+
player.loop = !store.get("sound-play-once");
873873
player.play();
874874
if ((method === 2 && store.get("no-check-work-time-end")) || (method === 1 && store.get("no-check-rest-time-end"))) {
875875
$("#skipper-container").css("display", "none");

0 commit comments

Comments
 (0)