Align starter pack opt-out with AppView state

This commit is contained in:
vineyardbovines
2026-09-01 14:40:38 -04:00
parent 364602a000
commit b9e218c543
2 changed files with 81 additions and 64 deletions
@@ -665,6 +665,7 @@ function OverflowMenu({
</Menu.ItemText> </Menu.ItemText>
<Menu.ItemIcon icon={CircleInfo} position="right" /> <Menu.ItemIcon icon={CircleInfo} position="right" />
</Menu.Item> </Menu.Item>
{starterPack.list ? (
<Menu.Item <Menu.Item
label={ label={
referenceListOptOut referenceListOptOut
@@ -681,6 +682,7 @@ function OverflowMenu({
)} )}
</Menu.ItemText> </Menu.ItemText>
</Menu.Item> </Menu.Item>
) : null}
</> </>
)} )}
</Menu.Outer> </Menu.Outer>
@@ -740,6 +742,7 @@ function OverflowMenu({
</Prompt.Actions> </Prompt.Actions>
</Prompt.Outer> </Prompt.Outer>
{starterPack.list ? (
<Prompt.Outer control={optOutDialogControl}> <Prompt.Outer control={optOutDialogControl}>
<Prompt.TitleText> <Prompt.TitleText>
{referenceListOptOut ? ( {referenceListOptOut ? (
@@ -785,6 +788,7 @@ function OverflowMenu({
<Prompt.Cancel /> <Prompt.Cancel />
</Prompt.Actions> </Prompt.Actions>
</Prompt.Outer> </Prompt.Outer>
) : null}
<CreateListFromStarterPackDialog <CreateListFromStarterPackDialog
control={convertToListDialogControl} control={convertToListDialogControl}
+16 -3
View File
@@ -113,17 +113,30 @@ export function useReferenceListOptOutMutation({
nextOptOut = result.uri nextOptOut = result.uri
} }
let didReadViewerState = false
await until( await until(
5, 5,
1e3, 1e3,
(value, error) => (value, error) => {
!error && if (error) return false
value.starterPack.list?.viewer?.referenceListOptOut === nextOptOut,
didReadViewerState = true
nextOptOut = value.starterPack.list?.viewer?.referenceListOptOut
// AppView ignores duplicate records and continues to expose the URI
// of the record it indexed first. Treat that viewer state as the
// source of truth instead of waiting for the newly-created URI.
return referenceListOptOut ? !nextOptOut : Boolean(nextOptOut)
},
async () => async () =>
await appviewClient.call(app.bsky.graph.getStarterPack, { await appviewClient.call(app.bsky.graph.getStarterPack, {
starterPack: starterPack.uri, starterPack: starterPack.uri,
}), }),
) )
if (!didReadViewerState) {
throw new Error('Unable to read starter pack opt-out state')
}
return nextOptOut return nextOptOut
}, },
onMutate: async ({referenceListOptOut}) => { onMutate: async ({referenceListOptOut}) => {