Skip to content

Commit 397b239

Browse files
authored
Merge pull request #102 from mengmeet/keep_chk
feat: add settings protection polling mechanism
2 parents 30ae97e + d2185ab commit 397b239

14 files changed

Lines changed: 123 additions & 10 deletions

src/components/settings.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,45 @@ const SettingsPerAcStateComponent: FC = () => {
259259
);
260260
};
261261

262+
const SettingsPollingComponent: FC = () => {
263+
const [enabled, setEnabled] = useState<boolean>(Settings.appPollingEnabled());
264+
const [show, setShow] = useState<boolean>(Settings.ensureEnable());
265+
266+
useEffect(() => {
267+
PluginManager.listenUpdateComponent(
268+
ComponentName.SETTINGS_POLLING,
269+
[ComponentName.SETTINGS_POLLING],
270+
(_ComponentName, updateType: string) => {
271+
if (updateType === UpdateType.UPDATE) {
272+
setEnabled(Settings.appPollingEnabled());
273+
setShow(Settings.ensureEnable());
274+
} else if (updateType === UpdateType.SHOW) {
275+
setShow(true);
276+
} else if (updateType === UpdateType.HIDE) {
277+
setShow(false);
278+
}
279+
}
280+
);
281+
}, []);
282+
283+
if (!show) return null;
284+
285+
return (
286+
<PanelSectionRow>
287+
<ToggleField
288+
label={localizationManager.getString(localizeStrEnum.SETTINGS_POLLING)}
289+
description={localizationManager.getString(
290+
localizeStrEnum.SETTINGS_POLLING_DESC
291+
)}
292+
checked={enabled}
293+
onChange={(value) => {
294+
Settings.setPollingEnabled(value);
295+
}}
296+
/>
297+
</PanelSectionRow>
298+
);
299+
};
300+
262301
export const SettingsComponent: FC<{
263302
isTab?: boolean;
264303
}> = ({ isTab = false }) => {
@@ -296,6 +335,7 @@ export const SettingsComponent: FC<{
296335
<SettingsEnableComponent />
297336
<SettingsPerAppComponent />
298337
<SettingsPerAcStateComponent />
338+
<SettingsPollingComponent />
299339
</>
300340
)}
301341
</PanelSection>

src/i18n/bulgarian.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "преди {{minutes}} минути",
102102
"HOURS_AGO": "преди {{hours}} часа",
103103
"DAYS_AGO": "преди {{days}} дни",
104-
"CLICK_TO_CHECK": "Кликнете за проверка на обновления"
104+
"CLICK_TO_CHECK": "Кликнете за проверка на обновления",
105+
"SETTINGS_POLLING": "Settings Protection",
106+
"SETTINGS_POLLING_DESC": "Periodically re-apply settings to prevent override by other tools"
105107
}

src/i18n/english.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,7 @@
105105
"MINUTES_AGO": "{{minutes}} minutes ago",
106106
"HOURS_AGO": "{{hours}} hours ago",
107107
"DAYS_AGO": "{{days}} days ago",
108-
"CLICK_TO_CHECK": "Click to check for updates"
108+
"CLICK_TO_CHECK": "Click to check for updates",
109+
"SETTINGS_POLLING": "Settings Protection",
110+
"SETTINGS_POLLING_DESC": "Periodically re-apply settings to prevent override by other tools"
109111
}

src/i18n/french.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "il y a {{minutes}} minutes",
102102
"HOURS_AGO": "il y a {{hours}} heures",
103103
"DAYS_AGO": "il y a {{days}} jours",
104-
"CLICK_TO_CHECK": "Cliquer pour vérifier les mises à jour"
104+
"CLICK_TO_CHECK": "Cliquer pour vérifier les mises à jour",
105+
"SETTINGS_POLLING": "Protection des paramètres",
106+
"SETTINGS_POLLING_DESC": "Réappliquer périodiquement les paramètres pour empêcher leur remplacement par d'autres outils"
105107
}

src/i18n/german.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "vor {{minutes}} Minuten",
102102
"HOURS_AGO": "vor {{hours}} Stunden",
103103
"DAYS_AGO": "vor {{days}} Tagen",
104-
"CLICK_TO_CHECK": "Klicken um nach Updates zu suchen"
104+
"CLICK_TO_CHECK": "Klicken um nach Updates zu suchen",
105+
"SETTINGS_POLLING": "Einstellungsschutz",
106+
"SETTINGS_POLLING_DESC": "Einstellungen regelmäßig erneut anwenden, um Überschreibung durch andere Tools zu verhindern"
105107
}

src/i18n/italian.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "{{minutes}} minuti fa",
102102
"HOURS_AGO": "{{hours}} ore fa",
103103
"DAYS_AGO": "{{days}} giorni fa",
104-
"CLICK_TO_CHECK": "Clicca per controllare gli aggiornamenti"
104+
"CLICK_TO_CHECK": "Clicca per controllare gli aggiornamenti",
105+
"SETTINGS_POLLING": "Protezione impostazioni",
106+
"SETTINGS_POLLING_DESC": "Riapplica periodicamente le impostazioni per evitare la sovrascrittura da parte di altri strumenti"
105107
}

src/i18n/japanese.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "{{minutes}}分前",
102102
"HOURS_AGO": "{{hours}}時間前",
103103
"DAYS_AGO": "{{days}}日前",
104-
"CLICK_TO_CHECK": "クリックして最新版を確認"
104+
"CLICK_TO_CHECK": "クリックして最新版を確認",
105+
"SETTINGS_POLLING": "設定保護",
106+
"SETTINGS_POLLING_DESC": "設定を定期的に再適用し、他のツールによる上書きを防止します"
105107
}

src/i18n/koreana.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "{{minutes}}분 전",
102102
"HOURS_AGO": "{{hours}}시간 전",
103103
"DAYS_AGO": "{{days}}일 전",
104-
"CLICK_TO_CHECK": "클릭하여 최신 버전 확인"
104+
"CLICK_TO_CHECK": "클릭하여 최신 버전 확인",
105+
"SETTINGS_POLLING": "설정 보호",
106+
"SETTINGS_POLLING_DESC": "설정을 주기적으로 다시 적용하여 다른 도구에 의한 덮어쓰기를 방지합니다"
105107
}

src/i18n/schinese.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,7 @@
105105
"MINUTES_AGO": "{{minutes}}分钟前",
106106
"HOURS_AGO": "{{hours}}小时前",
107107
"DAYS_AGO": "{{days}}天前",
108-
"CLICK_TO_CHECK": "点击检查最新版本"
108+
"CLICK_TO_CHECK": "点击检查最新版本",
109+
"SETTINGS_POLLING": "设置保护",
110+
"SETTINGS_POLLING_DESC": "定期重新应用设置,防止被其他工具覆盖"
109111
}

src/i18n/tchinese.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@
101101
"MINUTES_AGO": "{{minutes}}分鐘前",
102102
"HOURS_AGO": "{{hours}}小時前",
103103
"DAYS_AGO": "{{days}}天前",
104-
"CLICK_TO_CHECK": "點擊檢查最新版本"
104+
"CLICK_TO_CHECK": "點擊檢查最新版本",
105+
"SETTINGS_POLLING": "設定保護",
106+
"SETTINGS_POLLING_DESC": "定期重新套用設定,防止被其他工具覆蓋"
105107
}

0 commit comments

Comments
 (0)