Skip to content

Commit

Permalink
feat(components): add premium feature toast on save
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Dec 3, 2023
1 parent 5c080a1 commit 455fdb1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/pages/posts/post/PostSave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { liveQuery } from 'dexie'
import { useObservable } from '@vueuse/rxjs'
import type { IPost } from '~/assets/js/post'
import { toast } from 'vue-sonner'
// TODO: Load this component in <suspense>
Expand All @@ -14,6 +15,8 @@
post: IPost
}>()
const { isPremium } = useUserData()
const postCount = useObservable(
//
liveQuery(() =>
Expand All @@ -28,6 +31,13 @@
const isPostSaved = computed(() => postCount.value > 0)
async function onClick() {
if (!isPremium.value) {
toast.info('Premium feature', {
description: 'Save posts to your device and enjoy them later'
})
return
}
switch (isPostSaved.value) {
case false: {
await savePost()
Expand Down

0 comments on commit 455fdb1

Please sign in to comment.