From 4ec406934e9b64df699d636b58f27d114c7cb3cd Mon Sep 17 00:00:00 2001
From: An Phan
Date: Tue, 12 Jan 2016 23:39:50 +0800
Subject: [PATCH] Add a setting to confirm Koel before closing
---
resources/assets/js/app.vue | 9 +++++++
.../main-wrapper/main-content/profile.vue | 25 ++++++++++++++++---
resources/assets/js/stores/preference.js | 1 +
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/resources/assets/js/app.vue b/resources/assets/js/app.vue
index 3a22e4c4..04b31604 100644
--- a/resources/assets/js/app.vue
+++ b/resources/assets/js/app.vue
@@ -80,6 +80,15 @@
// Ask for user's notification permission.
this.requestNotifPermission();
+ // To confirm or not to confirm closing, it's a question.
+ window.onbeforeunload = e => {
+ if (!this.prefs.confirmClosing) {
+ return;
+ }
+
+ return 'You asked Koel to confirm before closing, so here it is.';
+ };
+
// Let all other compoenents know we're ready.
this.$broadcast('koel:ready');
}, () => this.authenticated = false);
diff --git a/resources/assets/js/components/main-wrapper/main-content/profile.vue b/resources/assets/js/components/main-wrapper/main-content/profile.vue
index 81539cbf..ee60cef7 100644
--- a/resources/assets/js/components/main-wrapper/main-content/profile.vue
+++ b/resources/assets/js/components/main-wrapper/main-content/profile.vue
@@ -41,8 +41,16 @@
@@ -66,7 +74,6 @@
Doing so will reload Koel, though.
-