tweak routes for edit
This commit is contained in:
@@ -325,6 +325,11 @@ function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) {
|
|||||||
getComponent={() => Wizard}
|
getComponent={() => Wizard}
|
||||||
options={{title: title(msg`Create a starter pack`), requireAuth: true}}
|
options={{title: title(msg`Create a starter pack`), requireAuth: true}}
|
||||||
/>
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="StarterPackEdit"
|
||||||
|
getComponent={() => Wizard}
|
||||||
|
options={{title: title(msg`Edit your starter pack`), requireAuth: true}}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ export type CommonNavigatorParams = {
|
|||||||
MessagesSettings: undefined
|
MessagesSettings: undefined
|
||||||
Feeds: undefined
|
Feeds: undefined
|
||||||
StarterPack: {name: string; rkey: string}
|
StarterPack: {name: string; rkey: string}
|
||||||
StarterPackWizard: {
|
StarterPackWizard: undefined
|
||||||
name?: string
|
StarterPackEdit: {
|
||||||
rkey?: string
|
rkey?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,8 +99,8 @@ export type AllNavigatorParams = CommonNavigatorParams & {
|
|||||||
MessagesTab: undefined
|
MessagesTab: undefined
|
||||||
Messages: {animation?: 'push' | 'pop'}
|
Messages: {animation?: 'push' | 'pop'}
|
||||||
StarterPack: {name: string; rkey: string}
|
StarterPack: {name: string; rkey: string}
|
||||||
StarterPackWizard: {
|
StarterPackWizard: undefined
|
||||||
name?: string
|
StarterPackEdit: {
|
||||||
rkey?: string
|
rkey?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -42,8 +42,6 @@ export const router = new Router({
|
|||||||
MessagesSettings: '/messages/settings',
|
MessagesSettings: '/messages/settings',
|
||||||
MessagesConversation: '/messages/:conversation',
|
MessagesConversation: '/messages/:conversation',
|
||||||
StarterPack: '/starter-pack/:name/:rkey',
|
StarterPack: '/starter-pack/:name/:rkey',
|
||||||
StarterPackWizard: [
|
StarterPackWizard: '/starter-pack/create',
|
||||||
'/starter-pack/create/:name/:rkey',
|
StarterPackEdit: '/starter-pack/edit/:rkey',
|
||||||
'/starter-pack/create',
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -249,9 +249,7 @@ function Header({
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
onPress={() =>
|
onPress={() => navigation.navigate('StarterPackEdit', {rkey})}>
|
||||||
navigation.navigate('StarterPackWizard', {name, rkey})
|
|
||||||
}>
|
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Edit</Trans>
|
<Trans>Edit</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import {
|
|||||||
useListMembersQuery,
|
useListMembersQuery,
|
||||||
} from 'state/queries/list-members'
|
} from 'state/queries/list-members'
|
||||||
import {useProfileQuery} from 'state/queries/profile'
|
import {useProfileQuery} from 'state/queries/profile'
|
||||||
import {useResolveDidQuery} from 'state/queries/resolve-uri'
|
|
||||||
import {
|
import {
|
||||||
invalidateStarterPack,
|
invalidateStarterPack,
|
||||||
useStarterPackQuery,
|
useStarterPackQuery,
|
||||||
@@ -62,24 +61,21 @@ import {Provider} from './State'
|
|||||||
|
|
||||||
export function Wizard({
|
export function Wizard({
|
||||||
route,
|
route,
|
||||||
}: NativeStackScreenProps<CommonNavigatorParams, 'StarterPackWizard'>) {
|
}: NativeStackScreenProps<
|
||||||
const {name, rkey} = route.params ?? {}
|
CommonNavigatorParams,
|
||||||
|
'StarterPackEdit' | 'StarterPackWizard'
|
||||||
|
>) {
|
||||||
|
const {rkey} = route.params ?? {}
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
const {
|
|
||||||
data: did,
|
|
||||||
isLoading: isLoadingDid,
|
|
||||||
isError: isErrorDid,
|
|
||||||
} = useResolveDidQuery(name)
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: starterPack,
|
data: starterPack,
|
||||||
isLoading: isLoadingStarterPack,
|
isLoading: isLoadingStarterPack,
|
||||||
isError: isErrorStarterPack,
|
isError: isErrorStarterPack,
|
||||||
} = useStarterPackQuery({did, rkey})
|
} = useStarterPackQuery({did: currentAccount!.did, rkey})
|
||||||
const listUri = starterPack?.list?.uri
|
const listUri = starterPack?.list?.uri
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -95,7 +91,7 @@ export function Wizard({
|
|||||||
isError: isErrorProfile,
|
isError: isErrorProfile,
|
||||||
} = useProfileQuery({did: currentAccount?.did})
|
} = useProfileQuery({did: currentAccount?.did})
|
||||||
|
|
||||||
const isEdit = Boolean(name && rkey)
|
const isEdit = Boolean(rkey)
|
||||||
const isReady =
|
const isReady =
|
||||||
(!isEdit || (isEdit && starterPack && listItems)) &&
|
(!isEdit || (isEdit && starterPack && listItems)) &&
|
||||||
profile &&
|
profile &&
|
||||||
@@ -105,14 +101,9 @@ export function Wizard({
|
|||||||
return (
|
return (
|
||||||
<ListMaybePlaceholder
|
<ListMaybePlaceholder
|
||||||
isLoading={
|
isLoading={
|
||||||
isLoadingDid ||
|
isLoadingStarterPack || isLoadingProfiles || isLoadingProfile
|
||||||
isLoadingStarterPack ||
|
|
||||||
isLoadingProfiles ||
|
|
||||||
isLoadingProfile
|
|
||||||
}
|
|
||||||
isError={
|
|
||||||
isErrorDid || isErrorStarterPack || isErrorProfiles || isErrorProfile
|
|
||||||
}
|
}
|
||||||
|
isError={isErrorStarterPack || isErrorProfiles || isErrorProfile}
|
||||||
errorMessage={_(msg`Could not find that starter pack`)}
|
errorMessage={_(msg`Could not find that starter pack`)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -129,7 +120,6 @@ export function Wizard({
|
|||||||
return (
|
return (
|
||||||
<Provider starterPack={starterPack} listItems={listItems}>
|
<Provider starterPack={starterPack} listItems={listItems}>
|
||||||
<WizardInner
|
<WizardInner
|
||||||
did={did}
|
|
||||||
rkey={rkey}
|
rkey={rkey}
|
||||||
createdAt={
|
createdAt={
|
||||||
AppBskyGraphStarterpack.isRecord(starterPack?.record)
|
AppBskyGraphStarterpack.isRecord(starterPack?.record)
|
||||||
@@ -146,7 +136,6 @@ export function Wizard({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function WizardInner({
|
function WizardInner({
|
||||||
did,
|
|
||||||
rkey,
|
rkey,
|
||||||
createdAt: initialCreatedAt,
|
createdAt: initialCreatedAt,
|
||||||
listUri: initialListUri,
|
listUri: initialListUri,
|
||||||
@@ -154,7 +143,6 @@ function WizardInner({
|
|||||||
profile,
|
profile,
|
||||||
moderationOpts,
|
moderationOpts,
|
||||||
}: {
|
}: {
|
||||||
did?: string
|
|
||||||
rkey?: string
|
rkey?: string
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
listUri?: string
|
listUri?: string
|
||||||
@@ -224,18 +212,18 @@ function WizardInner({
|
|||||||
const currUiStrings = wizardUiStrings[state.currentStep]
|
const currUiStrings = wizardUiStrings[state.currentStep]
|
||||||
|
|
||||||
const invalidateQueries = async () => {
|
const invalidateQueries = async () => {
|
||||||
if (!did || !rkey) return
|
if (!rkey) return
|
||||||
|
|
||||||
if (initialListUri) {
|
if (initialListUri) {
|
||||||
await invalidateListMembersQuery({queryClient, uri: initialListUri})
|
await invalidateListMembersQuery({queryClient, uri: initialListUri})
|
||||||
}
|
}
|
||||||
await invalidateActorStarterPacksQuery({
|
await invalidateActorStarterPacksQuery({
|
||||||
queryClient,
|
queryClient,
|
||||||
did,
|
did: currentAccount!.did,
|
||||||
})
|
})
|
||||||
await invalidateStarterPack({
|
await invalidateStarterPack({
|
||||||
queryClient,
|
queryClient,
|
||||||
did,
|
did: currentAccount!.did,
|
||||||
rkey,
|
rkey,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -244,7 +232,7 @@ function WizardInner({
|
|||||||
dispatch({type: 'SetProcessing', processing: true})
|
dispatch({type: 'SetProcessing', processing: true})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (did && rkey) {
|
if (rkey) {
|
||||||
// Editing an existing starter pack
|
// Editing an existing starter pack
|
||||||
let list: {uri: string; cid: string} | undefined = initialListUri
|
let list: {uri: string; cid: string} | undefined = initialListUri
|
||||||
? {uri: initialListUri, cid: ''}
|
? {uri: initialListUri, cid: ''}
|
||||||
@@ -457,7 +445,7 @@ function WizardInner({
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Container
|
<Container
|
||||||
showDeleteBtn={Boolean(did && rkey)}
|
showDeleteBtn={Boolean(rkey)}
|
||||||
deleteStarterPack={deleteStarterPack}>
|
deleteStarterPack={deleteStarterPack}>
|
||||||
{state.currentStep === 'Details' ? (
|
{state.currentStep === 'Details' ? (
|
||||||
<StepDetails />
|
<StepDetails />
|
||||||
|
|||||||
Reference in New Issue
Block a user