From b3d6d4cad744d3abb65a29290378dfdbc481fa57 Mon Sep 17 00:00:00 2001 From: Matt Solomon Date: Fri, 19 Mar 2021 13:53:05 -0700 Subject: [PATCH] Setup state and store for toggling advanced mode --- frontend/src/layouts/BaseLayout.vue | 64 +++++++++++++++++++---------- frontend/src/store/settings.ts | 17 ++++++++ 2 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 frontend/src/store/settings.ts diff --git a/frontend/src/layouts/BaseLayout.vue b/frontend/src/layouts/BaseLayout.vue index ff211072b..3a6af0672 100644 --- a/frontend/src/layouts/BaseLayout.vue +++ b/frontend/src/layouts/BaseLayout.vue @@ -52,8 +52,13 @@
-
- {{ userDisplayName }} +
+ + {{ userDisplayName }} + + + 🧙 Advanced mode is on +
@@ -71,29 +76,44 @@
-
+ +
+ - + + + + Advanced mode {{ advancedMode ? 'on' : 'off' }} + + + + Enables advanced features such as private key export, additional recipient ID options, and event + scanning settings. Use with caution! + + +
-
+ + +
Built by ScopeLift
-
+ + +
@@ -112,19 +132,18 @@ diff --git a/frontend/src/store/settings.ts b/frontend/src/store/settings.ts new file mode 100644 index 000000000..53b831c4a --- /dev/null +++ b/frontend/src/store/settings.ts @@ -0,0 +1,17 @@ +import { computed, onMounted, ref } from '@vue/composition-api'; +import { LocalStorage } from 'quasar'; + +// Shared state between instances +const advancedMode = ref(false); // true if user has advanced mode turned on + +// Composition function for managing state +export default function useSettingsStore() { + onMounted(() => (advancedMode.value = Boolean(LocalStorage.getItem('advanced-mode')))); + + function toggleAdvancedMode() { + advancedMode.value = !advancedMode.value; + LocalStorage.set('advanced-mode', advancedMode.value); + } + + return { toggleAdvancedMode, advancedMode: computed(() => advancedMode.value) }; +}