Skip to content

Commit fcfd598

Browse files
authored
type route params (keybase#24998)
1 parent e7ccfb2 commit fcfd598

113 files changed

Lines changed: 989 additions & 716 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎shared/chat/blocking/block-modal/container.tsx‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1+
import * as Chat2Gen from '../../../actions/chat2-gen'
2+
import * as Constants from '../../../constants/users'
13
import * as Container from '../../../util/container'
24
import * as RouteTreeGen from '../../../actions/route-tree-gen'
3-
import BlockModal, {BlockType, NewBlocksMap, ReportSettings, BlockModalContext} from '.'
4-
import * as UsersGen from '../../../actions/users-gen'
55
import * as TeamsGen from '../../../actions/teams-gen'
6-
import * as Chat2Gen from '../../../actions/chat2-gen'
7-
import * as Constants from '../../../constants/users'
6+
import * as UsersGen from '../../../actions/users-gen'
7+
import BlockModal, {type BlockType, type NewBlocksMap, type ReportSettings} from '.'
88
import {leaveTeamWaitingKey} from '../../../constants/teams'
99

10-
type OwnProps = Container.RouteProps<{
11-
blockUserByDefault?: boolean
12-
context?: BlockModalContext
13-
convID?: string
14-
others?: Array<string>
15-
team?: string
16-
username?: string
17-
}>
10+
type OwnProps = Container.RouteProps<'chatBlockingModal'>
1811

1912
export default Container.connect(
2013
(state: Container.TypedState, ownProps: OwnProps) => {
21-
const teamname = Container.getRouteProps(ownProps, 'team', undefined)
14+
const teamname = ownProps.route.params?.team ?? undefined
2215
const waitingForLeave = teamname ? Container.anyWaiting(state, leaveTeamWaitingKey(teamname)) : false
2316
const waitingForBlocking = Container.anyWaiting(state, Constants.setUserBlocksWaitingKey)
2417
const waitingForReport = Container.anyWaiting(state, Constants.reportUserWaitingKey)
25-
let others = Container.getRouteProps(ownProps, 'others', undefined)
26-
let adderUsername = Container.getRouteProps(ownProps, 'username', undefined)
18+
let others = ownProps.route.params?.others ?? undefined
19+
let adderUsername = ownProps.route.params?.username ?? undefined
2720
if (others?.length === 1 && !adderUsername) {
2821
adderUsername = others[0]
2922
others = undefined
@@ -32,9 +25,9 @@ export default Container.connect(
3225
return {
3326
_allKnownBlocks: state.users.blockMap,
3427
adderUsername,
35-
blockUserByDefault: Container.getRouteProps(ownProps, 'blockUserByDefault', false),
36-
context: Container.getRouteProps(ownProps, 'context', undefined),
37-
convID: Container.getRouteProps(ownProps, 'convID', undefined),
28+
blockUserByDefault: ownProps.route.params?.blockUserByDefault ?? false,
29+
context: ownProps.route.params?.context ?? undefined,
30+
convID: ownProps.route.params?.convID ?? undefined,
3831
finishWaiting: waitingForLeave || waitingForBlocking || waitingForReport,
3932
loadingWaiting: Container.anyWaiting(state, Constants.getUserBlocksWaitingKey),
4033
otherUsernames: others && others.length > 0 ? others : undefined,

‎shared/chat/conversation/attachment-fullscreen/container.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {imgMaxWidthRaw} from '../messages/attachment/image/image-render'
1212

1313
const blankMessage = Constants.makeMessageAttachment({})
1414

15-
type OwnProps = Container.RouteProps<{conversationIDKey: Types.ConversationIDKey; ordinal: Types.Ordinal}>
15+
type OwnProps = Container.RouteProps<'chatAttachmentFullscreen'>
1616

1717
const Connected = (props: OwnProps) => {
18-
const conversationIDKey = Container.getRouteProps(props, 'conversationIDKey', Constants.noConversationIDKey)
19-
const inOrdinal = Container.getRouteProps(props, 'ordinal', 0)
18+
const conversationIDKey = props.route.params?.conversationIDKey ?? Constants.noConversationIDKey
19+
const inOrdinal = props.route.params?.ordinal ?? 0
2020
const [ordinal, setOrdinal] = React.useState(inOrdinal)
2121
const [autoPlay, setAutoPlay] = React.useState(true)
2222
const dispatch = Container.useDispatch()

‎shared/chat/conversation/attachment-get-titles/container.tsx‎

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,24 @@
11
import * as Chat2Gen from '../../../actions/chat2-gen'
22
import * as Constants from '../../../constants/chat2'
3-
import * as RPCChatTypes from '../../../constants/types/rpc-chat-gen'
4-
import * as Types from '../../../constants/types/chat2'
5-
import * as FsTypes from '../../../constants/types/fs'
6-
import GetTitles, {Info} from '.'
73
import * as Container from '../../../util/container'
4+
import * as FsTypes from '../../../constants/types/fs'
85
import * as RouteTreeGen from '../../../actions/route-tree-gen'
6+
import GetTitles, {type Info} from '.'
7+
import type * as RPCChatTypes from '../../../constants/types/rpc-chat-gen'
8+
import type * as Types from '../../../constants/types/chat2'
99

10-
type OwnProps = Container.RouteProps<{
11-
conversationIDKey: Types.ConversationIDKey
12-
pathAndOutboxIDs: Array<Types.PathAndOutboxID>
13-
selectConversationWithReason?: 'extension' | 'files'
14-
// If tlfName is set, we'll use Chat2Gen.createAttachmentsUpload. Otherwise
15-
// Chat2Gen.createAttachFromDragAndDrop is used.
16-
tlfName?: string
17-
// don't use the drag drop functionality, just upload the outbox IDs
18-
noDragDrop?: Boolean
19-
}>
10+
type OwnProps = Container.RouteProps<'chatAttachmentGetTitles'>
2011

2112
const noOutboxIds: Array<Types.PathAndOutboxID> = []
2213

2314
export default Container.connect(
2415
() => ({}),
2516
(dispatch: Container.TypedDispatch, ownProps: OwnProps) => {
26-
const conversationIDKey = Container.getRouteProps(
27-
ownProps,
28-
'conversationIDKey',
29-
Constants.noConversationIDKey
30-
)
31-
const tlfName = Container.getRouteProps(ownProps, 'tlfName', undefined)
32-
const noDragDrop = Container.getRouteProps(ownProps, 'noDragDrop', false)
33-
const pathAndOutboxIDs = Container.getRouteProps(ownProps, 'pathAndOutboxIDs', noOutboxIds)
34-
const selectConversationWithReason = Container.getRouteProps(
35-
ownProps,
36-
'selectConversationWithReason',
37-
undefined
38-
)
17+
const conversationIDKey = ownProps.route.params?.conversationIDKey ?? Constants.noConversationIDKey
18+
const tlfName = ownProps.route.params?.tlfName ?? undefined
19+
const noDragDrop = ownProps.route.params?.noDragDrop ?? false
20+
const pathAndOutboxIDs = ownProps.route.params?.pathAndOutboxIDs ?? noOutboxIds
21+
const selectConversationWithReason = ownProps.route.params?.selectConversationWithReason ?? undefined
3922
return {
4023
onCancel: () => {
4124
dispatch(
@@ -76,7 +59,7 @@ export default Container.connect(
7659
}
7760
},
7861
(_, dispatchProps, ownProps: OwnProps) => {
79-
const pathAndOutboxIDs = Container.getRouteProps(ownProps, 'pathAndOutboxIDs', noOutboxIds)
62+
const pathAndOutboxIDs = ownProps.route.params?.pathAndOutboxIDs ?? noOutboxIds
8063
return {
8164
onCancel: dispatchProps.onCancel,
8265
onSubmit: dispatchProps.onSubmit,

‎shared/chat/conversation/bot/confirm.tsx‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import * as React from 'react'
22
import * as Container from '../../../util/container'
3-
import * as Types from '../../../constants/types/chat2'
43
import * as Chat2Gen from '../../../actions/chat2-gen'
54
import * as Kb from '../../../common-adapters'
65
import * as Constants from '../../../constants/chat2'
76
import * as RouteTreeGen from '../../../actions/route-tree-gen'
8-
import * as TeamTypes from '../../../constants/types/teams'
7+
import type * as Types from '../../../constants/types/chat2'
98
import {useBotConversationIDKey} from './install'
109

11-
type LoaderProps = Container.RouteProps<{
12-
botUsername: string
13-
conversationIDKey?: Types.ConversationIDKey
14-
teamID?: TeamTypes.TeamID
15-
}>
10+
type LoaderProps = Container.RouteProps<'chatConfirmRemoveBot'>
1611

1712
const ConfirmBotRemoveLoader = (props: LoaderProps) => {
18-
const botUsername = Container.getRouteProps(props, 'botUsername', '')
19-
const inConvIDKey = Container.getRouteProps(props, 'conversationIDKey', undefined)
20-
const teamID = Container.getRouteProps(props, 'teamID', undefined)
13+
const botUsername = props.route.params?.botUsername ?? ''
14+
const inConvIDKey = props.route.params?.conversationIDKey ?? undefined
15+
const teamID = props.route.params?.teamID ?? undefined
2116
const conversationIDKey = useBotConversationIDKey(inConvIDKey, teamID)
2217
return <ConfirmBotRemove botUsername={botUsername} conversationIDKey={conversationIDKey} />
2318
}

‎shared/chat/conversation/bot/install.tsx‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ export const useBotConversationIDKey = (inConvIDKey?: Types.ConversationIDKey, t
3434
return conversationIDKey
3535
}
3636

37-
type LoaderProps = Container.RouteProps<{
38-
botUsername: string
39-
conversationIDKey?: Types.ConversationIDKey
40-
teamID?: TeamTypes.TeamID
41-
}>
37+
type LoaderProps = Container.RouteProps<'chatInstallBot'>
4238

4339
const InstallBotPopupLoader = (props: LoaderProps) => {
44-
const botUsername = Container.getRouteProps(props, 'botUsername', '')
45-
const inConvIDKey = Container.getRouteProps(props, 'conversationIDKey', undefined)
46-
const teamID = Container.getRouteProps(props, 'teamID', undefined)
40+
const botUsername = props.route.params?.botUsername ?? ''
41+
const inConvIDKey = props.route.params?.conversationIDKey ?? undefined
42+
const teamID = props.route.params?.teamID ?? undefined
4743
const conversationIDKey = useBotConversationIDKey(inConvIDKey, teamID)
4844
return <InstallBotPopup botUsername={botUsername} conversationIDKey={conversationIDKey} />
4945
}

‎shared/chat/conversation/bot/search.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import * as React from 'react'
22
import * as Container from '../../../util/container'
33
import * as Kb from '../../../common-adapters'
4-
import * as Types from '../../../constants/types/chat2'
54
import * as Constants from '../../../constants/bots'
65
import * as BotsGen from '../../../actions/bots-gen'
76
import * as RouteTreeGen from '../../../actions/route-tree-gen'
8-
import * as RPCTypes from '../../../constants/types/rpc-gen'
97
import * as Styles from '../../../styles'
10-
import * as TeamTypes from '../../../constants/types/teams'
8+
import type * as RPCTypes from '../../../constants/types/rpc-gen'
119
import {Bot} from '../info-panel/bot'
1210
import debounce from 'lodash/debounce'
1311

14-
type Props = Container.RouteProps<{conversationIDKey?: Types.ConversationIDKey; teamID?: TeamTypes.TeamID}>
12+
type Props = Container.RouteProps<'chatSearchBots'>
1513

1614
const renderSectionHeader = ({section}: any) => {
1715
return <Kb.SectionDivider label={section.title} />
@@ -21,8 +19,8 @@ const userEmptyPlaceholder = '---EMPTYUSERS---'
2119
const resultEmptyPlaceholder = '---EMPTYRESULT---'
2220

2321
const SearchBotPopup = (props: Props) => {
24-
const conversationIDKey = Container.getRouteProps(props, 'conversationIDKey', undefined)
25-
const teamID = Container.getRouteProps(props, 'teamID', undefined)
22+
const conversationIDKey = props.route.params?.conversationIDKey ?? undefined
23+
const teamID = props.route.params?.teamID ?? undefined
2624
const [lastQuery, setLastQuery] = React.useState('')
2725
const featuredBotsMap = Container.useSelector(state => state.chat2.featuredBotsMap)
2826
const results = Container.useSelector(state => state.chat2.botSearchResults)

‎shared/chat/conversation/bot/team-picker.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {Avatars, TeamAvatar} from '../../avatars'
1010
import debounce from 'lodash/debounce'
1111
import logger from '../../../logger'
1212

13-
type Props = Container.RouteProps<{botUsername: string}>
13+
type Props = Container.RouteProps<'chatInstallBotPick'>
1414

1515
const BotTeamPicker = (props: Props) => {
16-
const botUsername = Container.getRouteProps(props, 'botUsername', '')
16+
const botUsername = props.route.params?.botUsername ?? ''
1717
const [term, setTerm] = React.useState('')
1818
const [results, setResults] = React.useState<Array<RPCChatTypes.ConvSearchHit>>([])
1919
const [waiting, setWaiting] = React.useState(false)
@@ -93,9 +93,7 @@ const BotTeamPicker = (props: Props) => {
9393
<Kb.Text type="BodyBigLink" onClick={onClose}>
9494
{'Cancel'}
9595
</Kb.Text>
96-
) : (
97-
undefined
98-
),
96+
) : undefined,
9997
title: 'Add to team or chat',
10098
}}
10199
>

‎shared/chat/conversation/container.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import Rekey from './rekey/container'
99
import {headerNavigationOptions} from './header-area/container'
1010
import {useFocusEffect, useNavigation} from '@react-navigation/core'
1111
import {tabBarStyle} from '../../router-v2/common'
12-
import type * as Types from '../../constants/types/chat2'
12+
import type {RouteProps} from '../../router-v2/route-params'
1313

1414
type ConvoType = 'error' | 'noConvo' | 'rekey' | 'youAreReset' | 'normal' | 'rekey'
1515

16-
type SwitchProps = Container.RouteProps<{conversationIDKey: Types.ConversationIDKey}>
16+
type SwitchProps = RouteProps<'chatConversation'>
1717
const hideTabBarStyle = {display: 'none'}
1818

1919
// due to timing issues if we go between convos we can 'lose track' of focus in / out
@@ -59,7 +59,7 @@ const Conversation = (p: SwitchProps) => {
5959
}, [tabNav])
6060
)
6161

62-
const conversationIDKey = Container.getRouteProps(p, 'conversationIDKey', Constants.noConversationIDKey)
62+
const conversationIDKey = p.route.params?.conversationIDKey ?? Constants.noConversationIDKey
6363
const meta = Container.useSelector(state => Constants.getMeta(state, conversationIDKey))
6464

6565
let type: ConvoType

‎shared/chat/conversation/fwd-msg/team-picker.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {Avatars, TeamAvatar} from '../../avatars'
1212
import debounce from 'lodash/debounce'
1313
import logger from '../../../logger'
1414

15-
type Props = Container.RouteProps<{srcConvID: Types.ConversationIDKey; ordinal: Types.Ordinal}>
15+
type Props = Container.RouteProps<'chatForwardMsgPick'>
1616

1717
const TeamPicker = (props: Props) => {
18-
const srcConvID = Container.getRouteProps(props, 'srcConvID', '')
19-
const ordinal = Container.getRouteProps(props, 'ordinal', 0)
18+
const srcConvID = props.route.params?.srcConvID ?? ''
19+
const ordinal = props.route.params?.ordinal ?? 0
2020
const message = Container.useSelector(state => Constants.getMessage(state, srcConvID, ordinal))
2121
const [term, setTerm] = React.useState('')
2222
const [results, setResults] = React.useState<Array<RPCChatTypes.ConvSearchHit>>([])

‎shared/chat/conversation/header-area/container.native.tsx‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as Tabs from '../../../constants/tabs'
1414
import {Alert} from 'react-native'
1515
import {DEBUGDump as DEBUGDumpView} from '../list-area/index.native'
1616
import {DEBUGDump as DEBUGDumpStore} from '../../../store/configure-store'
17+
import {getRouteParamsFromRoute} from '../../../router-v2/route-params'
1718

1819
type OwnProps = {
1920
conversationIDKey: Types.ConversationIDKey
@@ -172,13 +173,17 @@ const BadgeHeaderLeftArray = ({conversationIDKey, ...rest}) => {
172173
return <HeaderLeftArrow badgeNumber={badgeNumber} {...rest} />
173174
}
174175

175-
export const headerNavigationOptions = (route: any) => ({
176-
headerLeft: (props: any) => {
177-
const {onLabelLayout, labelStyle, ...rest} = props
178-
return <BadgeHeaderLeftArray {...rest} conversationIDKey={route.params?.conversationIDKey} />
179-
},
180-
headerRight: () => <HeaderAreaRight conversationIDKey={route.params?.conversationIDKey} />,
181-
headerTitle: () => <HeaderArea conversationIDKey={route.params?.conversationIDKey} />,
182-
})
176+
export const headerNavigationOptions = (route: unknown) => {
177+
const conversationIDKey =
178+
getRouteParamsFromRoute<'chatConversation'>(route)?.conversationIDKey ?? Constants.noConversationIDKey
179+
return {
180+
headerLeft: (props: any) => {
181+
const {onLabelLayout, labelStyle, ...rest} = props
182+
return <BadgeHeaderLeftArray {...rest} conversationIDKey={conversationIDKey} />
183+
},
184+
headerRight: () => <HeaderAreaRight conversationIDKey={conversationIDKey} />,
185+
headerTitle: () => <HeaderArea conversationIDKey={conversationIDKey} />,
186+
}
187+
}
183188

184189
export default HeaderArea

0 commit comments

Comments
 (0)