mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
Add following relation to frontend state when redeeming invites
This commit is contained in:
parent
f85ce81e30
commit
e3e495dbcb
@ -3,6 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { toast } from 'react-toastify'
|
||||
|
||||
import { useAuth } from '#components/Auth/useAuth'
|
||||
import { useUpdateItem } from '#components/Map/hooks/useItems'
|
||||
import { useMyProfile } from '#components/Map/hooks/useMyProfile'
|
||||
import { MapOverlayPage } from '#components/Templates/MapOverlayPage'
|
||||
|
||||
@ -22,6 +23,7 @@ export function InvitePage({ inviteApi, itemsApi }: Props) {
|
||||
const { isAuthenticated, isInitialized: isAuthenticationInitialized } = useAuth()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const updateItem = useUpdateItem()
|
||||
|
||||
const { myProfile, isMyProfileLoaded, createEmptyProfile } = useMyProfile()
|
||||
|
||||
@ -57,8 +59,26 @@ export function InvitePage({ inviteApi, itemsApi }: Props) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!invitingProfile) {
|
||||
toast.error('Inviting profile not found')
|
||||
return
|
||||
}
|
||||
|
||||
await redeemInvite(id, myActualProfile.id)
|
||||
|
||||
// Add new relation to local state
|
||||
updateItem({
|
||||
...myActualProfile,
|
||||
relations: [
|
||||
...(myActualProfile.relations ?? []),
|
||||
{
|
||||
type: 'is_following',
|
||||
direction: 'outgoing',
|
||||
related_items_id: invitingProfile.id,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
setRedeemingDone(true)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user