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}`
|
||||
}
|
||||
}
|
||||
|
||||
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 onDeleteStarterPack = async () => {
|
||||
if (!starterPack.list) {
|
||||
logger.error(`Unable to delete starterpack because list is missing`)
|
||||
return
|
||||
}
|
||||
|
||||
deleteStarterPack({
|
||||
rkey: routeParams.rkey,
|
||||
// TODO need to fix types
|
||||
listUri: starterPack.list!.uri,
|
||||
listUri: starterPack.list.uri,
|
||||
})
|
||||
logEvent('starterPack:delete', {})
|
||||
}
|
||||
@@ -449,14 +453,16 @@ function OverflowMenu({
|
||||
</Menu.Outer>
|
||||
</Menu.Root>
|
||||
|
||||
<ReportDialog
|
||||
params={{
|
||||
type: 'starterpack',
|
||||
uri: starterPack.list!.uri,
|
||||
cid: starterPack.list!.cid,
|
||||
}}
|
||||
control={reportDialogControl}
|
||||
/>
|
||||
{starterPack.list && (
|
||||
<ReportDialog
|
||||
control={reportDialogControl}
|
||||
params={{
|
||||
type: 'starterpack',
|
||||
uri: starterPack.list.uri,
|
||||
cid: starterPack.list.cid,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Prompt.Outer control={deleteDialogControl}>
|
||||
<Prompt.TitleText>
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import {until} from 'lib/async/until'
|
||||
import {createStarterPackList} from 'lib/generate-starterpack'
|
||||
import {
|
||||
createStarterPackUri,
|
||||
httpStarterPackUriToAtUri,
|
||||
parseStarterPackUri,
|
||||
} from 'lib/strings/starter-pack'
|
||||
@@ -261,7 +262,6 @@ export function useDeleteStarterPackMutation({
|
||||
throw new Error(`Requires logged in user`)
|
||||
}
|
||||
|
||||
// TODO parallel?
|
||||
await agent.app.bsky.graph.list.delete({
|
||||
repo: agent.session.did,
|
||||
rkey: new AtUri(listUri).rkey,
|
||||
@@ -272,6 +272,17 @@ export function useDeleteStarterPackMutation({
|
||||
})
|
||||
},
|
||||
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 invalidateActorStarterPacksQuery({
|
||||
queryClient,
|
||||
|
||||
Reference in New Issue
Block a user