diff options
Diffstat (limited to 'src/main/assets/scripts.js')
-rw-r--r-- | src/main/assets/scripts.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 3c83bba4..12c4d9b2 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -251,6 +251,10 @@ function closeDialogListener(ev) { } } +/** + * + * @param {Response} response + */ function handleErrors(response) { if (!response.ok) { throw Error(response.statusText) @@ -310,15 +314,14 @@ function showCommentForm(mid, rid) { method: 'POST', body: formData, credentials: 'include' - }).then(handleErrors) - .then(response => response.json()) + }).then(response => response.json()) .then(result => { if (result.newMessage) { window.location.hash = `#${result.newMessage.rid}` + window.location.reload() } else { alert(result.text) } - window.location.reload() }).catch(error => { alert(error.message) }) @@ -535,7 +538,7 @@ function fetchUserUri(dataUri) { const registerServiceWorker = () => { const publicKey = 'BPU0LniKKR0QiaUvILPd9AystmSOU8rWDZobxKm7IJN5HYxOSQdktRdc74TZvyRS9_kyUz7LDN6gUAmAVOmObAU' - navigator.serviceWorker.register('/sw.js', { scope: '/' }) + navigator.serviceWorker.register(new URL('./sw.js', import.meta.url), { scope: '/' }) navigator.serviceWorker.ready.then(reg => { return reg.pushManager.subscribe({ userVisibleOnly: true, @@ -663,8 +666,7 @@ ready(() => { method: 'POST', body: formData, credentials: 'include' - }).then(handleErrors) - .then(response => response.json()) + }).then(response => response.json()) .then(result => { if (result.newMessage) { window.location.href = new URL(`/m/${result.newMessage.mid}`, window.location.href).href |