Skip to content

Commit

Permalink
Add approved count after success approve
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jul 15, 2024
1 parent 7e5053f commit 93631a2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/services/datahub/events/subscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '../generated-query'
import { getSocialProfileQuery } from '../identity/query'
import { callIdToPostIdMap } from '../posts/mutation'
import { getUnapprovedMemesCountQuery } from '../posts/query'
import { getProfileQuery } from '../profiles/query'
import { getGamificationTasksErrorQuery } from '../tasks/query'
import { datahubSubscription } from '../utils'
Expand Down Expand Up @@ -232,6 +233,36 @@ async function processSubscriptionEvent(
return
}

if (eventData.meta.callName === SocialCallName.SynthSetPostApproveStatus) {
const extension = eventData.meta.extension
const updatedPostId = extension?.postId ?? ''
const creatorAddress = extension?.creatorAddress ?? ''
const rootPostId = extension?.rootPostId ?? ''
const profile = getProfileQuery.getQueryData(client, creatorAddress)
toast.custom((t) => (
<Toast
t={t}
type='default'
title={`You have approved a meme from ${
profile?.profileSpace?.content?.name || 'user'
}`}
/>
))
getUnapprovedMemesCountQuery.setQueryData(
client,
{ address: creatorAddress, chatId: rootPostId },
(oldCount) => {
if (!oldCount) return oldCount
return {
...oldCount,
ids: [...oldCount.ids, updatedPostId],
approved: oldCount.approved + 1,
}
}
)
return
}

if (eventData.meta.callName === SocialCallName.SynthGamificationClaimTask) {
claimTaskErrorStore.set(eventData.meta.code)

Expand Down

0 comments on commit 93631a2

Please sign in to comment.