Align starter pack opt-out with AppView state
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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}) => {
|
||||
|
||||
Reference in New Issue
Block a user