Skip to content

Commit 5e3e9c8

Browse files
- CHG: Experimenting more with install prompt.
1 parent 5b41e81 commit 5e3e9c8

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/components/HelpToolbar.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,29 @@
2020

2121
<script lang="ts" setup>
2222
import emitter from 'tiny-emitter/instance'
23+
import { coreStore } from '@/store'
24+
25+
const store = coreStore()
2326
2427
const expanded = ref<boolean>(false)
2528
const showInstall = ref<boolean>(false)
2629
2730
let deferredPrompt: any
2831
32+
watch(expanded, async newValue => {
33+
if (newValue === false && showInstall.value) {
34+
store.setToolbarHiddenAfterInstallShown(true)
35+
}
36+
})
37+
2938
async function install () {
3039
if (deferredPrompt) {
3140
deferredPrompt.prompt()
3241
const { outcome } = await deferredPrompt.userChoice
3342
3443
emitter.emit('plausible-event', { key: 'installation', props: { userChoice: outcome } })
3544
45+
showInstall.value = false
3646
deferredPrompt = undefined
3747
}
3848
}
@@ -44,7 +54,9 @@ onMounted(() => {
4454
// Stash the event so it can be triggered later.
4555
deferredPrompt = e
4656
47-
expanded.value = true
57+
if (!store.toolbarHiddenAfterInstallShown) {
58+
expanded.value = true
59+
}
4860
showInstall.value = true
4961
})
5062
})

src/store/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const coreStore = defineStore('core', {
5353
autoSelectSearch: false,
5454
autoProgressInputs: true,
5555
categoryCountInline: 4,
56+
toolbarHiddenAfterInstallShown: false,
5657
mainDisplayMode: MAIN_DISPLAY_MODE_AUTO,
5758
plausible: {
5859
plausibleDomain: null,
@@ -105,7 +106,8 @@ export const coreStore = defineStore('core', {
105106
storeChangelogVersionNumber: (state): string | null => state.changelogVersionNumber,
106107
storeDeviceConfig: (state): any => state.deviceConfig,
107108
storeShowFullTraitDescription: (state): boolean => state.showFullTraitDescription,
108-
storeCategoryCountInline: (state): number => state.categoryCountInline
109+
storeCategoryCountInline: (state): number => state.categoryCountInline,
110+
storeToolbarHiddenAfterInstallShown: (state): boolean => state.toolbarHiddenAfterInstallShown,
109111
},
110112
actions: {
111113
setUniqueClientId: function (newUniqueClientId: string) {
@@ -261,6 +263,9 @@ export const coreStore = defineStore('core', {
261263
},
262264
setCategoryCountInline: function (newCategoryCountInline: number) {
263265
this.categoryCountInline = newCategoryCountInline
266+
},
267+
setToolbarHiddenAfterInstallShown: function (newToolbarHiddenAfterInstallShown: boolean) {
268+
this.toolbarHiddenAfterInstallShown = newToolbarHiddenAfterInstallShown
264269
}
265270
},
266271
persist: {

0 commit comments

Comments
 (0)