Add guarded reboot control
This commit is contained in:
@@ -32,8 +32,14 @@
|
||||
return (String(value || '').match(/[가-힣ㄱ-ㅎㅏ-ㅣ]/g) || []).length;
|
||||
}
|
||||
|
||||
function deviceNameFromUser() {
|
||||
const name = prompt('등록할까요? 등록하려면 디바이스 이름을 지정하세요 최소 2글자.', '');
|
||||
async function deviceNameFromUser() {
|
||||
const promptFn = window.customPrompt || (() => Promise.resolve(null));
|
||||
const name = await promptFn('등록할 기기 이름을 입력하세요. 한글 2글자 이상이어야 합니다.', {
|
||||
title: 'Push 등록',
|
||||
okText: '등록',
|
||||
placeholder: '휴대폰',
|
||||
autocomplete: 'off',
|
||||
});
|
||||
|
||||
if (name === null) {
|
||||
return null;
|
||||
@@ -251,7 +257,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const deviceName = deviceNameFromUser();
|
||||
const deviceName = await deviceNameFromUser();
|
||||
if (deviceName === null) {
|
||||
await refreshButton();
|
||||
return;
|
||||
@@ -283,7 +289,12 @@
|
||||
}
|
||||
|
||||
async function unsubscribe() {
|
||||
if (!confirm('푸시 기기 삭제할까요?')) {
|
||||
const confirmFn = window.customConfirm || (() => Promise.resolve(false));
|
||||
if (!await confirmFn('현재 브라우저의 Push 구독을 삭제할까요?', {
|
||||
title: 'Push 삭제',
|
||||
okText: '삭제',
|
||||
danger: true,
|
||||
})) {
|
||||
await refreshButton();
|
||||
return;
|
||||
}
|
||||
@@ -316,7 +327,11 @@
|
||||
const active = button.dataset.active === '1';
|
||||
const job = active ? unsubscribe() : subscribe();
|
||||
job.catch(error => {
|
||||
alert(error.message || 'Push failed');
|
||||
const alertFn = window.customAlert || (() => Promise.resolve());
|
||||
alertFn(error.message || 'Push failed', {
|
||||
title: 'Push 오류',
|
||||
danger: true,
|
||||
});
|
||||
refreshButton().catch(() => {});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user