Skip to content

Commit

Permalink
refactor: Show tutorial for all users (#327)
Browse files Browse the repository at this point in the history
* refactor: Show onboarding again for all users

* fix(tutorials): Improve tutorials store types
  • Loading branch information
Hanziness committed Jan 8, 2023
1 parent c2453f0 commit dcd456c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions components/tutorial/_tutorialView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { markRaw } from 'vue'
import tutorialOnboarding from './tutorialOnboarding.vue'
import { useTutorials } from '~~/stores/tutorials'
import { useMain, flags } from '~~/stores/main'
import { useMain } from '~~/stores/main'
const tutorialsStore = useTutorials()
const mainStore = useMain()
Expand All @@ -26,7 +26,7 @@ watch(() => tutorialsStore.currentTutorial, (newValue) => {
onMounted(() => {
state.enableComponent = tutorialsStore.currentTutorial != null
if (!mainStore.isFlagActive(flags.STORE_RESTORED)) {
if (!mainStore.restoredStores.includes('tutorials')) {
tutorialsStore.openTutorial('onboarding')
}
})
Expand Down
9 changes: 9 additions & 0 deletions plugins/store-persist.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const breakingChanges: BreakingChange[] = [
'The settings\' theming data was restructured.'
],
affectedStores: ['settings']
},
{
from: '1.0.0',
to: '1.4.1',
reason: [
'The app was rebranded to FocusTide.'
],
affectedStores: ['tutorials']
}
]

Expand Down Expand Up @@ -74,6 +82,7 @@ function restoreStore (store: Store) {

const mainStore = useMain()
mainStore.registerFlag(flags.STORE_RESTORED)
mainStore.restoredStores.push(store.$id)
}
}

Expand Down
2 changes: 1 addition & 1 deletion stores/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useMain = defineStore('main', {
state: () => ({
version: useRuntimeConfig().public.PACKAGE_VERSION,
flags: [] as string[],
skippedStores: {} as Record<string, string[]>
restoredStores: [] as string[]
}),

getters: {
Expand Down
8 changes: 4 additions & 4 deletions stores/tutorials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import { defineStore } from 'pinia'

export const useTutorials = defineStore('tutorials', {
state: () => ({
openTutorials: []
openTutorials: [] as string[]
}),

getters: {
isTutorialOpen: (state) => {
return tutorialId => state.openTutorials.indexOf(tutorialId) === 0
return (tutorialId: string) => state.openTutorials.indexOf(tutorialId) === 0
},

currentTutorial: state => state.openTutorials[0] ?? null
},

actions: {
openTutorial (tutorialId) {
openTutorial (tutorialId: string) {
if (!this.openTutorials.includes(tutorialId)) {
this.openTutorials.push(tutorialId)
}
},

closeTutorial (tutorialId) {
closeTutorial (tutorialId: string) {
const tutorialIndex = this.openTutorials.indexOf(tutorialId)
if (tutorialIndex >= 0) {
this.openTutorials.splice(tutorialIndex, 1)
Expand Down

0 comments on commit dcd456c

Please sign in to comment.