Skip to content

Commit

Permalink
feat: enable saving posts without Premium
Browse files Browse the repository at this point in the history
and add tutorial
  • Loading branch information
AlejandroAkbal committed Jan 17, 2024
1 parent 79d547b commit 6ec13e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 4 additions & 3 deletions components/pages/posts/post/PostSave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
post: IPost
}>()
const { isPremium } = useUserData()
const { tutorialLongClickTag } = useAppStatistics()
const postCount = useObservable(
//
Expand All @@ -31,15 +31,16 @@
const isPostSaved = computed(() => postCount.value.length > 0)
async function onClick() {
if (!isPremium.value) {
if (!tutorialLongClickTag.value) {
toast.info('Premium feature', {
description: 'Save posts to your device and enjoy them later',
action: {
label: 'Subscribe',
onClick: () => navigateTo('/premium')
}
})
return
tutorialLongClickTag.value = true
}
switch (isPostSaved.value) {
Expand Down
9 changes: 8 additions & 1 deletion composables/useAppStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ let timesTheAppHasBeenOpened = ref<number>(0)

let tutorialLongClickTag = ref<boolean>(false)

let tutorialSavePost = ref<boolean>(false)

if (process.client) {
timesTheAppHasBeenOpened = useStorage('statistics-appOpenedCount', 0, localStorage, {
writeDefaults: false
Expand All @@ -12,6 +14,10 @@ if (process.client) {
tutorialLongClickTag = useStorage('tutorial-longClickTag', false, localStorage, {
writeDefaults: false
})

tutorialSavePost = useStorage('tutorial-savePost', false, localStorage, {
writeDefaults: false
})
}

timesTheAppHasBeenOpened.value++
Expand All @@ -20,6 +26,7 @@ export function useAppStatistics() {
return {
timesTheAppHasBeenOpened,

tutorialLongClickTag
tutorialLongClickTag,
tutorialSavePost
}
}

0 comments on commit 6ec13e0

Please sign in to comment.