Skip to content

Commit

Permalink
Applied code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
musidlo committed Dec 24, 2024
1 parent 2d78331 commit d94f1c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/app/features/profile/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function ProfileScreen({ sendid: propSendid }: ProfileScreenProps) {
const { user, profile: currentUserProfile } = useUser()
const media = useMedia()
const [queryParams, setRootParams] = useRootScreenParams()
const { isProfileInfoVisible } = queryParams
const isProfileInfoVisible = queryParams.modal === 'profile'

const {
data,
Expand All @@ -57,7 +57,7 @@ export function ProfileScreen({ sendid: propSendid }: ProfileScreenProps) {

const toggleIsProfileInfoVisible = () => {
setRootParams(
{ ...queryParams, isProfileInfoVisible: !isProfileInfoVisible },
{ ...queryParams, modal: isProfileInfoVisible ? undefined : 'profile' },
{ webBehavior: 'replace' }
)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/features/send/SendAmountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function SendAmountForm() {
const { recipient, idType } = sendParams
const { data: profile } = useProfileLookup(idType ?? 'tag', recipient ?? '')
const [queryParams, setRootParams] = useRootScreenParams()
const { isProfileInfoVisible } = queryParams
const isProfileInfoVisible = queryParams.modal === 'profile'
const [isInputFocused, setIsInputFocused] = useState<boolean>(false)
const { resolvedTheme } = useThemeSetting()
const { coin: usdc } = useCoin('USDC')
Expand Down Expand Up @@ -99,7 +99,7 @@ export function SendAmountForm() {

const toggleIsProfileInfoVisible = () => {
setRootParams(
{ ...queryParams, isProfileInfoVisible: !isProfileInfoVisible },
{ ...queryParams, modal: isProfileInfoVisible ? undefined : 'profile' },
{ webBehavior: 'replace' }
)
}
Expand Down
15 changes: 6 additions & 9 deletions packages/app/routers/params.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type RootParams = {
nav?: 'home' | 'settings'
token?: allCoins[number]['token']
search?: string
isProfileInfoVisible?: boolean
modal?: 'profile'
}

const { useParam: useRootParam, useParams: useRootParams } = createParam<RootParams>()
Expand All @@ -31,28 +31,25 @@ const useSearch = () => {
return [search, setSearchParam] as const
}

const useIsProfileInfoVisible = () => {
const [isProfileInfoVisible, setIsProfileInfoVisible] = useRootParam('isProfileInfoVisible', {
initial: undefined,
parse: (value) => value === 'true',
})
const useModal = () => {
const [modal, setModalParam] = useRootParam('modal')

return [isProfileInfoVisible, setIsProfileInfoVisible] as const
return [modal, setModalParam] as const
}

export const useRootScreenParams = () => {
const { setParams } = useRootParams()
const [nav] = useNav()
const [token] = useToken()
const [search] = useSearch()
const [isProfileInfoVisible] = useIsProfileInfoVisible()
const [modal] = useModal()

return [
{
nav,
token,
search,
isProfileInfoVisible,
modal,
},
setParams,
] as const
Expand Down

0 comments on commit d94f1c8

Please sign in to comment.