Skip to content

Commit f8445d0

Browse files
authored
Use native SectionList (#28516)
1 parent 28d6213 commit f8445d0

File tree

186 files changed

+1351
-2689
lines changed

Some content is hidden

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

186 files changed

+1351
-2689
lines changed

shared/app/global-errors/hook.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ const useData = () => {
4545
}
4646
}, [clearCountdown])
4747

48-
C.useOnUnMountOnce(() => {
49-
clearCountdown()
50-
})
51-
52-
C.useOnMountOnce(() => {
53-
resetError(!!error)
54-
})
55-
5648
const resetError = React.useCallback(
5749
(newError: boolean) => {
5850
setSize(newError ? 'Small' : 'Closed')
@@ -68,6 +60,14 @@ const useData = () => {
6860
[clearCountdown, onDismiss]
6961
)
7062

63+
C.useOnUnMountOnce(() => {
64+
clearCountdown()
65+
})
66+
67+
C.useOnMountOnce(() => {
68+
resetError(!!error)
69+
})
70+
7171
React.useEffect(() => {
7272
const id = setTimeout(
7373
() => {

shared/app/global-errors/index.desktop.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react'
21
import logger from '@/logger'
32
import * as Kb from '@/common-adapters'
43
import {ignoreDisconnectOverlay} from '@/local-debug.desktop'

shared/app/global-errors/index.native.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react'
21
import * as Kb from '@/common-adapters'
32
import NativeScrollView from '@/common-adapters/scroll-view.native'
43
import useData from './hook'

shared/chat/audio/audio-recorder.native.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ const useIconAndOverlay = (p: {
179179
}
180180
const cleanupOverlayTimeout = () => {
181181
clearTimeout(id)
182-
// eslint-disable-next-line
183182
id = 0
184183
}
185184

@@ -766,10 +765,10 @@ const SendRecordingButton = (props: {fadeSV: SVN; lockedSV: SVN; sendRecording:
766765

767766
const AudioCounter = () => {
768767
const [seconds, setSeconds] = React.useState(0)
769-
const startTime = React.useRef(Date.now())
768+
const [startTime] = React.useState(() => Date.now())
770769
React.useEffect(() => {
771770
const timer = setTimeout(() => {
772-
setSeconds((Date.now() - startTime.current) / 1000)
771+
setSeconds((Date.now() - startTime) / 1000)
773772
}, 1000)
774773
return () => clearTimeout(timer)
775774
}, [seconds, startTime])

shared/chat/blocking/block-modal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const ReportOptions = (props: ReportOptionsProps) => {
127127
// In order to have this play nicely with scrolling and keyboards, put all the stuff in a List.
128128
type Item = 'topStuff' | {username: string}
129129

130-
const BlockModal = React.memo((p: Props) => {
130+
const BlockModal = React.memo(function BlockModal(p: Props) {
131131
const {finishWaiting, onClose, refreshBlocks, context, blockUserByDefault, otherUsernames} = p
132132
const {reportsUserByDefault, flagUserByDefault, conversationIDKey, adderUsername} = p
133133
const [blockTeam, setBlockTeam] = React.useState(true)

shared/chat/conversation/bot/search.tsx

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,29 @@ import {Bot} from '../info-panel/bot'
88

99
type Props = {teamID?: T.Teams.TeamID}
1010

11-
const renderSectionHeader = ({section}: {section: {title: string}}) => {
11+
const renderSectionHeader = ({section}: {section: {title?: string}}) => {
1212
return <Kb.SectionDivider label={section.title} />
1313
}
1414

15-
const userEmptyPlaceholder = '---EMPTYUSERS---'
16-
const resultEmptyPlaceholder = '---EMPTYRESULT---'
15+
const userEmptyPlaceholder = '---EMPTYUSERS---' as const
16+
const resultEmptyPlaceholder = '---EMPTYRESULT---' as const
17+
18+
type Item =
19+
| {type: 'bot'; bot: T.RPCGen.FeaturedBot}
20+
| {type: 'str'; str: string}
21+
| {type: 'dummy'; value: typeof userEmptyPlaceholder | typeof resultEmptyPlaceholder}
22+
type Section = Omit<Kb.SectionType<Item>, 'title'> & {title: string}
1723

1824
const SearchBotPopup = (props: Props) => {
1925
const conversationIDKey = C.useChatContext(s => s.id)
2026
const teamID = props.teamID
2127
const [lastQuery, setLastQuery] = React.useState('')
2228
const featuredBotsMap = C.useBotsState(s => s.featuredBotsMap)
2329
const botSearchResults = C.useBotsState(s => s.botSearchResults)
24-
const waiting = C.Waiting.useAnyWaiting([C.Bots.waitingKeyBotSearchUsers, C.Bots.waitingKeyBotSearchFeatured])
30+
const waiting = C.Waiting.useAnyWaiting([
31+
C.Bots.waitingKeyBotSearchUsers,
32+
C.Bots.waitingKeyBotSearchFeatured,
33+
])
2534
const clearModals = C.useRouterState(s => s.dispatch.clearModals)
2635
const onClose = () => {
2736
clearModals()
@@ -52,60 +61,66 @@ const SearchBotPopup = (props: Props) => {
5261
getFeaturedBots()
5362
})
5463

55-
const botData: Array<T.RPCGen.FeaturedBot | string> =
64+
const botData: Array<Item> =
5665
lastQuery.length > 0
57-
? botSearchResults.get(lastQuery)?.bots.slice() ?? []
58-
: C.Bots.getFeaturedSorted(featuredBotsMap)
66+
? (botSearchResults
67+
.get(lastQuery)
68+
?.bots.slice()
69+
.map(bot => ({bot, type: 'bot'}) as const) ?? [])
70+
: C.Bots.getFeaturedSorted(featuredBotsMap).map(bot => ({bot, type: 'bot'}))
5971
if (!botData.length && !waiting) {
60-
botData.push(resultEmptyPlaceholder)
72+
botData.push({type: 'dummy', value: resultEmptyPlaceholder})
6173
}
62-
const botSection = {
74+
const botSection: Section = {
6375
data: botData,
64-
renderItem: ({index, item}: {index: number; item: T.RPCGen.FeaturedBot | string}) => {
65-
return item === resultEmptyPlaceholder ? (
76+
renderItem: ({index, item}: {index: number; item: Item}) => {
77+
return item.type === 'dummy' && item.value === resultEmptyPlaceholder ? (
6678
<Kb.Text
6779
style={{...Styles.padding(Styles.globalMargins.tiny, Styles.globalMargins.tiny)}}
6880
type="BodySmall"
6981
>
7082
No results were found
7183
</Kb.Text>
72-
) : typeof item !== 'string' ? (
73-
<Bot {...item} onClick={onSelect} firstItem={index === 0} />
84+
) : item.type === 'bot' ? (
85+
<Bot {...item.bot} onClick={onSelect} firstItem={index === 0} />
7486
) : null
7587
},
7688
title: 'Featured bots',
7789
}
78-
const userData = !lastQuery.length
79-
? [userEmptyPlaceholder]
80-
: botSearchResults
81-
.get(lastQuery)
82-
?.users.filter(u => !featuredBotsMap.get(u))
83-
.slice(0, 3) ?? []
90+
const userData: Array<Item> = !lastQuery.length
91+
? [{type: 'dummy', value: userEmptyPlaceholder} as const]
92+
: (
93+
botSearchResults
94+
.get(lastQuery)
95+
?.users.filter(u => !featuredBotsMap.get(u))
96+
.slice(0, 3) ?? []
97+
).map(str => ({str, type: 'str'}) as const)
98+
8499
if (!userData.length && !waiting) {
85-
userData.push(resultEmptyPlaceholder)
100+
userData.push({type: 'dummy', value: resultEmptyPlaceholder} as const)
86101
}
87-
const usersSection = {
102+
const usersSection: Section = {
88103
data: userData,
89-
renderItem: ({item}: {item: string}) => {
104+
renderItem: ({item}: {item: Item}) => {
90105
return (
91106
<Kb.Box2
92107
direction="horizontal"
93108
fullWidth={true}
94109
style={{...Styles.padding(Styles.globalMargins.tiny, Styles.globalMargins.tiny)}}
95110
>
96-
{item === userEmptyPlaceholder ? (
111+
{item.type === 'dummy' && item.value === userEmptyPlaceholder ? (
97112
<Kb.Text type="BodySmall">Enter a bot username above</Kb.Text>
98-
) : item === resultEmptyPlaceholder ? (
113+
) : item.type === 'dummy' && item.value === resultEmptyPlaceholder ? (
99114
<Kb.Text type="BodySmall">No results were found</Kb.Text>
100-
) : (
115+
) : item.type === 'str' ? (
101116
<Kb.NameWithIcon
102-
username={item}
117+
username={item.str}
103118
horizontal={true}
104119
colorFollowing={true}
105120
onClick={onSelect}
106121
clickType="onClick"
107122
/>
108-
)}
123+
) : null}
109124
</Kb.Box2>
110125
)
111126
},

shared/chat/conversation/giphy/index.desktop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const GiphySearch = () => {
4040
>
4141
<Kb.Box2 direction="horizontal" style={styles.instructionsContainer} fullWidth={true} gap="xtiny">
4242
<Kb.Text style={styles.instructions} type="BodySmall">
43-
Tip: hit 'Enter' now to send a random GIF.
43+
{"Tip: hit 'Enter' now to send a random GIF."}
4444
</Kb.Text>
4545
<Kb.Text
4646
style={styles.instructions}

0 commit comments

Comments
 (0)