summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-12-29 17:20:24 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-12-29 17:20:24 +0900
commite6112506df73a8a38bb8b5a1fee5dd3149e989aa (patch)
tree1861d40d389f33703677d9e0d986e17b75625f33 /packages/frontend/src/components
parent:art: (diff)
downloadsharkey-e6112506df73a8a38bb8b5a1fee5dd3149e989aa.tar.gz
sharkey-e6112506df73a8a38bb8b5a1fee5dd3149e989aa.tar.bz2
sharkey-e6112506df73a8a38bb8b5a1fee5dd3149e989aa.zip
通知設定が開けないのを修正
Diffstat (limited to 'packages/frontend/src/components')
-rw-r--r--packages/frontend/src/components/MkPushNotificationAllowButton.vue32
1 files changed, 18 insertions, 14 deletions
diff --git a/packages/frontend/src/components/MkPushNotificationAllowButton.vue b/packages/frontend/src/components/MkPushNotificationAllowButton.vue
index b356fd3b89..b98c814f24 100644
--- a/packages/frontend/src/components/MkPushNotificationAllowButton.vue
+++ b/packages/frontend/src/components/MkPushNotificationAllowButton.vue
@@ -126,7 +126,7 @@ function encode(buffer: ArrayBuffer | null) {
* Convert the URL safe base64 string to a Uint8Array
* @param base64String base64 string
*/
- function urlBase64ToUint8Array(base64String: string): Uint8Array {
+function urlBase64ToUint8Array(base64String: string): Uint8Array {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/-/g, '+')
@@ -141,25 +141,29 @@ function encode(buffer: ArrayBuffer | null) {
return outputArray;
}
-navigator.serviceWorker.ready.then(async swr => {
- registration = swr;
+if (navigator.serviceWorker == null) {
+ // TODO: よしなに?
+} else {
+ navigator.serviceWorker.ready.then(async swr => {
+ registration = swr;
- pushSubscription = await registration.pushManager.getSubscription();
+ pushSubscription = await registration.pushManager.getSubscription();
- if (instance.swPublickey && ('PushManager' in window) && $i && $i.token) {
- supported = true;
+ if (instance.swPublickey && ('PushManager' in window) && $i && $i.token) {
+ supported = true;
- if (pushSubscription) {
- const res = await api('sw/show-registration', {
- endpoint: pushSubscription.endpoint,
- });
+ if (pushSubscription) {
+ const res = await api('sw/show-registration', {
+ endpoint: pushSubscription.endpoint,
+ });
- if (res) {
- pushRegistrationInServer = res;
+ if (res) {
+ pushRegistrationInServer = res;
+ }
}
}
- }
-});
+ });
+}
defineExpose({
pushRegistrationInServer: $$(pushRegistrationInServer),