From 21f1eda1f5ac8ac1c29a51fb8f7e700e0e15fb02 Mon Sep 17 00:00:00 2001 From: Tristan Schneider Date: Tue, 15 Dec 2020 16:07:11 +0100 Subject: [PATCH] fix missing config file handling for notifications --- index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 8afd779..4626b77 100644 --- a/index.php +++ b/index.php @@ -127,6 +127,8 @@ $config_data = json_decode($raw_json_config, false); return response.text().then((text) => { config_data = JSON.parse(text); }); + }).catch(() => { + config_data = Object(); // leave empty }); } @@ -142,7 +144,7 @@ $config_data = json_decode($raw_json_config, false); if (Notification.permission == 'granted') { navigator.serviceWorker.getRegistration().then(function(reg) { reg.showNotification("Neues Wort auf " + (config_data.title ? config_data.title : "OWE"), - { body: word, icon: config_data.logo.image_path ? config_data.logo.image_path : "OWE_Logo.png", requireInteraction: true }); + { body: word, icon: (config_data.logo? config_data.logo.image_path : "OWE_Logo.png"), requireInteraction: true }); }); } }