Skip to content

Commit

Permalink
fix: JavaScript repeats execution during hydration [SPMVP-7194]
Browse files Browse the repository at this point in the history
  • Loading branch information
arielllin authored and DanSnow committed Apr 2, 2024
1 parent b0adab3 commit 18b3d31
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/karbon/src/runtime/article/components/ArticleBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
// @ts-expect-error virtual file
import { editorBlocks } from '#build/editor-blocks.mjs'
const { $paywall } = useNuxtApp()
const { $paywall, isHydrating } = useNuxtApp()
const { loadAll: fixArticleEmbed } = useEmbed()
const root = ref<HTMLElement>()
Expand All @@ -39,10 +39,12 @@ const paywallID = computed(() => `paywall-${articleID.value || crypto.randomUUID
const articlePlan = computed(() => article?.plan || ArticlePlan.Free)
const getDecryptKey = useDecryptClient<ViewableApiResult>()
watchEffect(() => {
if (!root.value) return
processingArticles(root.value, fixArticleEmbed)
})
if (!isHydrating) {
watchEffect(() => {
if (!root.value) return
processingArticles(root.value, fixArticleEmbed)
})
}
const { state: articleSegments, execute } = useAsyncState<Segment[]>(async () => {
return await decryptPaidContent(
Expand Down

0 comments on commit 18b3d31

Please sign in to comment.