From 5688b2adf7bd17bec379a1255f4443894bad331c Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 10 Jun 2021 17:54:37 +0200 Subject: [PATCH] Safely check the global appName and handle its inexistence Signed-off-by: Christoph Wurst --- src/components/AppContent/AppContent.vue | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/AppContent/AppContent.vue b/src/components/AppContent/AppContent.vue index 5a1d784428..603e9f2ceb 100644 --- a/src/components/AppContent/AppContent.vue +++ b/src/components/AppContent/AppContent.vue @@ -172,11 +172,10 @@ export default { /** * Specify the config key for the pane config sizes * Default is the global var appName if you use the webpack-vue-config - * Otherwise it will be undefined and you will have to provide one */ paneConfigKey: { type: String, - default: appName, + default: '', }, /** @@ -203,8 +202,21 @@ export default { computed: { paneConfigID() { - // Using the webpack-vue-config, appName is a global variable - return `pane-list-size-${this.paneConfigKey}` + // If provided, let's use it + if (this.paneConfigKey !== '') { + return `pane-list-size-${this.paneConfigKey}` + } + + try { + // Using the webpack-vue-config, appName is a global variable + // This will throw a ReferenceError when the global variable is missing + // In that case either you provide paneConfigKey or else it fallback + // to a global storage key + return `pane-list-size-${appName}` + } catch (e) { + console.info('[INFO] AppContent:', 'falling back to global nextcloud pane config') + return 'pane-list-size-nextcloud' + } }, detailsPaneSize() {