Fix deletion invalidation, add guards
This commit is contained in:
@@ -89,3 +89,13 @@ export function getStarterPackOgCard(
|
|||||||
return `https://ogcard.cdn.bsky.app/start/${didOrStarterPack.creator.did}/${rkey}`
|
return `https://ogcard.cdn.bsky.app/start/${didOrStarterPack.creator.did}/${rkey}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createStarterPackUri({
|
||||||
|
did,
|
||||||
|
rkey,
|
||||||
|
}: {
|
||||||
|
did: string
|
||||||
|
rkey: string
|
||||||
|
}): string | null {
|
||||||
|
return new AtUri(`at://${did}/app.bsky.graph.starterpack/${rkey}`).toString()
|
||||||
|
}
|
||||||
|
|||||||
@@ -368,10 +368,14 @@ function OverflowMenu({
|
|||||||
const isOwn = starterPack.creator.did === currentAccount?.did
|
const isOwn = starterPack.creator.did === currentAccount?.did
|
||||||
|
|
||||||
const onDeleteStarterPack = async () => {
|
const onDeleteStarterPack = async () => {
|
||||||
|
if (!starterPack.list) {
|
||||||
|
logger.error(`Unable to delete starterpack because list is missing`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
deleteStarterPack({
|
deleteStarterPack({
|
||||||
rkey: routeParams.rkey,
|
rkey: routeParams.rkey,
|
||||||
// TODO need to fix types
|
listUri: starterPack.list.uri,
|
||||||
listUri: starterPack.list!.uri,
|
|
||||||
})
|
})
|
||||||
logEvent('starterPack:delete', {})
|
logEvent('starterPack:delete', {})
|
||||||
}
|
}
|
||||||
@@ -449,14 +453,16 @@ function OverflowMenu({
|
|||||||
</Menu.Outer>
|
</Menu.Outer>
|
||||||
</Menu.Root>
|
</Menu.Root>
|
||||||
|
|
||||||
|
{starterPack.list && (
|
||||||
<ReportDialog
|
<ReportDialog
|
||||||
|
control={reportDialogControl}
|
||||||
params={{
|
params={{
|
||||||
type: 'starterpack',
|
type: 'starterpack',
|
||||||
uri: starterPack.list!.uri,
|
uri: starterPack.list.uri,
|
||||||
cid: starterPack.list!.cid,
|
cid: starterPack.list.cid,
|
||||||
}}
|
}}
|
||||||
control={reportDialogControl}
|
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<Prompt.Outer control={deleteDialogControl}>
|
<Prompt.Outer control={deleteDialogControl}>
|
||||||
<Prompt.TitleText>
|
<Prompt.TitleText>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
import {until} from 'lib/async/until'
|
import {until} from 'lib/async/until'
|
||||||
import {createStarterPackList} from 'lib/generate-starterpack'
|
import {createStarterPackList} from 'lib/generate-starterpack'
|
||||||
import {
|
import {
|
||||||
|
createStarterPackUri,
|
||||||
httpStarterPackUriToAtUri,
|
httpStarterPackUriToAtUri,
|
||||||
parseStarterPackUri,
|
parseStarterPackUri,
|
||||||
} from 'lib/strings/starter-pack'
|
} from 'lib/strings/starter-pack'
|
||||||
@@ -261,7 +262,6 @@ export function useDeleteStarterPackMutation({
|
|||||||
throw new Error(`Requires logged in user`)
|
throw new Error(`Requires logged in user`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO parallel?
|
|
||||||
await agent.app.bsky.graph.list.delete({
|
await agent.app.bsky.graph.list.delete({
|
||||||
repo: agent.session.did,
|
repo: agent.session.did,
|
||||||
rkey: new AtUri(listUri).rkey,
|
rkey: new AtUri(listUri).rkey,
|
||||||
@@ -272,6 +272,17 @@ export function useDeleteStarterPackMutation({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSuccess: async (_, {listUri, rkey}) => {
|
onSuccess: async (_, {listUri, rkey}) => {
|
||||||
|
const uri = createStarterPackUri({
|
||||||
|
did: agent.session!.did,
|
||||||
|
rkey,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (uri) {
|
||||||
|
await whenAppViewReady(agent, uri, v => {
|
||||||
|
return Boolean(v?.data?.starterPack) === false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
await invalidateListMembersQuery({queryClient, uri: listUri})
|
await invalidateListMembersQuery({queryClient, uri: listUri})
|
||||||
await invalidateActorStarterPacksQuery({
|
await invalidateActorStarterPacksQuery({
|
||||||
queryClient,
|
queryClient,
|
||||||
|
|||||||
Reference in New Issue
Block a user