Tweaks to add to starter pack dialog (#8957)
This commit is contained in:
@@ -78,7 +78,6 @@ export function StarterPackDialog({
|
|||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<StarterPackList
|
<StarterPackList
|
||||||
control={control}
|
|
||||||
onStartWizard={wrappedNavToWizard}
|
onStartWizard={wrappedNavToWizard}
|
||||||
targetDid={targetDid}
|
targetDid={targetDid}
|
||||||
enabled={enabled}
|
enabled={enabled}
|
||||||
@@ -122,21 +121,19 @@ function Empty({onStartWizard}: {onStartWizard: () => void}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function StarterPackList({
|
function StarterPackList({
|
||||||
control,
|
|
||||||
onStartWizard,
|
onStartWizard,
|
||||||
targetDid,
|
targetDid,
|
||||||
enabled,
|
enabled,
|
||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogControlProps
|
|
||||||
onStartWizard: () => void
|
onStartWizard: () => void
|
||||||
targetDid: string
|
targetDid: string
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const control = Dialog.useDialogContext()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
refetch,
|
|
||||||
isError,
|
isError,
|
||||||
isLoading,
|
isLoading,
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
@@ -147,15 +144,7 @@ function StarterPackList({
|
|||||||
const membershipItems =
|
const membershipItems =
|
||||||
data?.pages.flatMap(page => page.starterPacksWithMembership) || []
|
data?.pages.flatMap(page => page.starterPacksWithMembership) || []
|
||||||
|
|
||||||
const _onRefresh = useCallback(async () => {
|
const onEndReached = useCallback(async () => {
|
||||||
try {
|
|
||||||
await refetch()
|
|
||||||
} catch (err) {
|
|
||||||
// Error handling is optional since this is just a refresh
|
|
||||||
}
|
|
||||||
}, [refetch])
|
|
||||||
|
|
||||||
const _onEndReached = useCallback(async () => {
|
|
||||||
if (isFetchingNextPage || !hasNextPage || isError) return
|
if (isFetchingNextPage || !hasNextPage || isError) return
|
||||||
try {
|
try {
|
||||||
await fetchNextPage()
|
await fetchNextPage()
|
||||||
@@ -239,9 +228,7 @@ function StarterPackList({
|
|||||||
? () => 'starter_pack_dialog_loader'
|
? () => 'starter_pack_dialog_loader'
|
||||||
: (item: StarterPackWithMembership) => item.starterPack.uri
|
: (item: StarterPackWithMembership) => item.starterPack.uri
|
||||||
}
|
}
|
||||||
refreshing={false}
|
onEndReached={onEndReached}
|
||||||
onRefresh={_onRefresh}
|
|
||||||
onEndReached={_onEndReached}
|
|
||||||
onEndReachedThreshold={0.1}
|
onEndReachedThreshold={0.1}
|
||||||
ListHeaderComponent={listHeader}
|
ListHeaderComponent={listHeader}
|
||||||
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
|
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
|
||||||
@@ -382,7 +369,7 @@ function StarterPackItem({
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
label={isInPack ? _(msg`Remove`) : _(msg`Add`)}
|
label={isInPack ? _(msg`Remove`) : _(msg`Add`)}
|
||||||
color={isInPack ? 'secondary' : 'primary'}
|
color={isInPack ? 'secondary' : 'primary_subtle'}
|
||||||
size="tiny"
|
size="tiny"
|
||||||
disabled={isPendingRefresh}
|
disabled={isPendingRefresh}
|
||||||
onPress={handleToggleMembership}>
|
onPress={handleToggleMembership}>
|
||||||
|
|||||||
Reference in New Issue
Block a user