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.ItemIcon icon={CircleInfo} position="right" />
</Menu.Item>
{starterPack.list ? (
<Menu.Item
label={
referenceListOptOut
@@ -681,6 +682,7 @@ function OverflowMenu({
)}
</Menu.ItemText>
</Menu.Item>
) : null}
</>
)}
</Menu.Outer>
@@ -740,6 +742,7 @@ function OverflowMenu({
</Prompt.Actions>
</Prompt.Outer>
{starterPack.list ? (
<Prompt.Outer control={optOutDialogControl}>
<Prompt.TitleText>
{referenceListOptOut ? (
@@ -785,6 +788,7 @@ function OverflowMenu({
<Prompt.Cancel />
</Prompt.Actions>
</Prompt.Outer>
) : null}
<CreateListFromStarterPackDialog
control={convertToListDialogControl}
+16 -3
View File
@@ -113,17 +113,30 @@ export function useReferenceListOptOutMutation({
nextOptOut = result.uri
}
let didReadViewerState = false
await until(
5,
1e3,
(value, error) =>
!error &&
value.starterPack.list?.viewer?.referenceListOptOut === nextOptOut,
(value, error) => {
if (error) return false
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 () =>
await appviewClient.call(app.bsky.graph.getStarterPack, {
starterPack: starterPack.uri,
}),
)
if (!didReadViewerState) {
throw new Error('Unable to read starter pack opt-out state')
}
return nextOptOut
},
onMutate: async ({referenceListOptOut}) => {