Skip to content

Commit 457ebc8

Browse files
authored
remove overlay parent hoc (keybase#25259)
1 parent 53cb0f0 commit 457ebc8

39 files changed

Lines changed: 940 additions & 1436 deletions

File tree

‎shared/chat/conversation/attachment-fullscreen/index.desktop.tsx‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ const Arrow = (props: ArrowProps) => {
2929
)
3030
}
3131

32-
const _Fullscreen = (p: Props & Kb.OverlayParentProps) => {
32+
const Fullscreen = (p: Props) => {
3333
const {path, title, message, progress, progressLabel} = p
3434
const {onNextAttachment, onPreviousAttachment, onClose, onDownloadAttachment, onShowInFinder, isVideo} = p
35-
const {setAttachmentRef, toggleShowingMenu, showingMenu, getAttachmentRef} = p
3635

3736
const [isZoomed, setIsZoomed] = React.useState(false)
3837
const onZoomed = React.useCallback((zoomed: boolean) => {
@@ -47,6 +46,16 @@ const _Fullscreen = (p: Props & Kb.OverlayParentProps) => {
4746
}
4847
const isDownloadError = !!message.transferErrMsg
4948

49+
const {toggleShowingPopup, showingPopup, popup, popupAnchor} = Kb.usePopup(attachTo => (
50+
<MessagePopup
51+
attachTo={attachTo}
52+
message={message}
53+
onHidden={toggleShowingPopup}
54+
position="bottom left"
55+
visible={showingPopup}
56+
/>
57+
))
58+
5059
return (
5160
<Kb.PopupDialog onClose={onClose} fill={true}>
5261
<Kb.Box style={styles.container}>
@@ -56,22 +65,16 @@ const _Fullscreen = (p: Props & Kb.OverlayParentProps) => {
5665
{title}
5766
</Kb.Markdown>
5867
<Kb.Icon
59-
ref={setAttachmentRef}
68+
ref={popupAnchor as any}
6069
type="iconfont-ellipsis"
6170
style={Styles.platformStyles({
6271
common: {marginLeft: Styles.globalMargins.tiny},
6372
isElectron: {cursor: 'pointer'},
6473
})}
6574
color={Styles.globalColors.black_50}
66-
onClick={toggleShowingMenu}
67-
/>
68-
<MessagePopup
69-
attachTo={getAttachmentRef}
70-
message={message}
71-
onHidden={toggleShowingMenu}
72-
position="bottom left"
73-
visible={showingMenu}
75+
onClick={toggleShowingPopup}
7476
/>
77+
{popup}
7578
</Kb.Box>
7679
{path && (
7780
<Kb.BoxGrow>
@@ -136,8 +139,6 @@ const _Fullscreen = (p: Props & Kb.OverlayParentProps) => {
136139
)
137140
}
138141

139-
const Fullscreen = Kb.OverlayParentHOC(_Fullscreen)
140-
141142
const styles = Styles.styleSheetCreate(
142143
() =>
143144
({

‎shared/chat/conversation/info-panel/add-people.tsx‎

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,24 @@
1-
import * as React from 'react'
2-
import * as Types from '../../../constants/types/chat2'
31
import * as Constants from '../../../constants/chat2'
2+
import * as Kb from '../../../common-adapters'
3+
import * as React from 'react'
4+
import * as RouteTreeGen from '../../../actions/route-tree-gen'
45
import * as Styles from '../../../styles'
5-
import * as TeamTypes from '../../../constants/types/teams'
66
import * as TeamsGen from '../../../actions/teams-gen'
7-
import * as Kb from '../../../common-adapters'
7+
import type * as TeamTypes from '../../../constants/types/teams'
8+
import type * as Types from '../../../constants/types/chat2'
89
import {connect} from '../../../util/container'
9-
import * as RouteTreeGen from '../../../actions/route-tree-gen'
1010

1111
type Props = {
1212
isAdmin: boolean
1313
isGeneralChannel: boolean
1414
onAddPeople: () => void
1515
onAddToChannel: () => void
16-
} & Kb.OverlayParentProps
16+
}
1717

1818
const _AddPeople = (props: Props) => {
19-
let menu: React.ReactNode = null
2019
let directAction: null | (() => void) = null
2120
let directLabel: string | null = null
2221
if (!props.isGeneralChannel) {
23-
// general channel & small teams don't need a menu
24-
const items: Kb.MenuItems = [
25-
{icon: 'iconfont-people', onClick: props.onAddPeople, title: 'To team'},
26-
{icon: 'iconfont-hash', onClick: props.onAddToChannel, title: 'To channel'},
27-
]
28-
menu = (
29-
<Kb.FloatingMenu
30-
attachTo={props.getAttachmentRef}
31-
visible={props.showingMenu}
32-
items={items}
33-
onHidden={props.toggleShowingMenu}
34-
position="bottom left"
35-
closeOnSelect={true}
36-
/>
37-
)
3822
} else {
3923
directAction = props.onAddPeople
4024
directLabel = 'Add people to team'
@@ -43,15 +27,36 @@ const _AddPeople = (props: Props) => {
4327
directAction = props.onAddToChannel
4428
directLabel = 'Add members to channel'
4529
}
30+
31+
const {toggleShowingPopup, showingPopup, popup, popupAnchor} = Kb.usePopup(attachTo => {
32+
if (!props.isGeneralChannel) {
33+
// general channel & small teams don't need a menu
34+
const items: Kb.MenuItems = [
35+
{icon: 'iconfont-people', onClick: props.onAddPeople, title: 'To team'},
36+
{icon: 'iconfont-hash', onClick: props.onAddToChannel, title: 'To channel'},
37+
]
38+
return (
39+
<Kb.FloatingMenu
40+
attachTo={attachTo}
41+
visible={showingPopup}
42+
items={items}
43+
onHidden={toggleShowingPopup}
44+
position="bottom left"
45+
closeOnSelect={true}
46+
/>
47+
)
48+
} else return null
49+
})
50+
4651
return (
4752
<Kb.Box2 direction="vertical" fullWidth={true}>
48-
{menu}
53+
{popup}
4954
<Kb.Button
5055
mode="Primary"
5156
type="Default"
52-
onClick={directAction || props.toggleShowingMenu}
57+
onClick={directAction || toggleShowingPopup}
5358
label={directLabel || 'Add people...'}
54-
ref={props.setAttachmentRef}
59+
ref={popupAnchor}
5560
style={styles.addButtonContainer}
5661
/>
5762
</Kb.Box2>
@@ -88,7 +93,7 @@ const AddPeople = connect(
8893
onAddPeople: () => d._onAddPeople(s.teamID),
8994
onAddToChannel: () => d._onAddToChannel(o.conversationIDKey, s.teamID),
9095
})
91-
)(Kb.OverlayParentHOC(_AddPeople))
96+
)(_AddPeople)
9297

9398
const styles = Styles.styleSheetCreate(
9499
() =>

‎shared/chat/conversation/info-panel/attachments.tsx‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as Styles from '../../../styles'
1010
import {formatAudioRecordDuration, formatTimeForMessages} from '../../../util/timestamp'
1111
import MessagePopup from '../messages/message-popup'
1212
import chunk from 'lodash/chunk'
13-
import type {OverlayParentProps} from '../../../common-adapters/overlay/parent-hoc'
1413
import {infoPanelWidth} from './common'
1514
import type {Section} from '../../../common-adapters/section-list'
1615

@@ -169,13 +168,24 @@ const MediaThumb = (props: MediaThumbProps) => {
169168
)
170169
}
171170

172-
type DocViewRowProps = {item: Doc} & OverlayParentProps
173-
174-
const _DocViewRow = (props: DocViewRowProps) => {
175-
const {item, toggleShowingMenu, getAttachmentRef, showingMenu} = props
171+
type DocViewRowProps = {item: Doc}
172+
173+
const DocViewRow = (props: DocViewRowProps) => {
174+
const {item} = props
175+
const {toggleShowingPopup, showingPopup, popup} = Kb.usePopup(attachTo =>
176+
item.message ? (
177+
<MessagePopup
178+
attachTo={attachTo}
179+
message={item.message}
180+
onHidden={toggleShowingPopup}
181+
position="top right"
182+
visible={showingPopup}
183+
/>
184+
) : null
185+
)
176186
return (
177187
<Kb.Box2 direction="vertical" fullWidth={true}>
178-
<Kb.ClickableBox onClick={item.onDownload} onLongPress={toggleShowingMenu}>
188+
<Kb.ClickableBox onClick={item.onDownload} onLongPress={toggleShowingPopup}>
179189
<Kb.Box2 direction="horizontal" fullWidth={true} style={styles.docRowContainer} gap="xtiny">
180190
<Kb.Icon type="icon-file-32" style={styles.docIcon} />
181191
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.docRowTitle}>
@@ -200,21 +210,11 @@ const _DocViewRow = (props: DocViewRowProps) => {
200210
</Kb.Text>
201211
</Kb.Box2>
202212
)}
203-
{Styles.isMobile && showingMenu && item.message && (
204-
<MessagePopup
205-
attachTo={getAttachmentRef}
206-
message={item.message}
207-
onHidden={toggleShowingMenu}
208-
position="top right"
209-
visible={showingMenu}
210-
/>
211-
)}
213+
{Styles.isMobile && showingPopup && item.message && popup}
212214
</Kb.Box2>
213215
)
214216
}
215217

216-
const DocViewRow = Kb.OverlayParentHOC(_DocViewRow)
217-
218218
type SelectorProps = {
219219
selectedView: RPCChatTypes.GalleryItemTyp
220220
onSelectView: (typ: RPCChatTypes.GalleryItemTyp) => void

‎shared/chat/conversation/info-panel/header.tsx‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import type * as ChatTypes from '../../../constants/types/chat2'
1111
import * as InfoPanelCommon from './common'
1212
import AddPeople from './add-people'
1313

14-
type SmallProps = {conversationIDKey: ChatTypes.ConversationIDKey} & Kb.OverlayParentProps
14+
type SmallProps = {conversationIDKey: ChatTypes.ConversationIDKey}
1515

1616
const gearIconSize = Styles.isMobile ? 24 : 16
1717

18-
const _TeamHeader = (props: SmallProps) => {
19-
const {conversationIDKey, toggleShowingMenu, getAttachmentRef, showingMenu, setAttachmentRef} = props
18+
const TeamHeader = (props: SmallProps) => {
19+
const {conversationIDKey} = props
2020
const dispatch = Container.useDispatch()
2121
const meta = Container.useSelector(state => Constants.getMeta(state, conversationIDKey))
2222
const {teamname, teamID, channelname, descriptionDecorated: description, membershipType, teamType} = meta
@@ -33,18 +33,23 @@ const _TeamHeader = (props: SmallProps) => {
3333
title += '#' + channelname
3434
}
3535
const isGeneralChannel = !!(channelname && channelname === 'general')
36+
37+
const {toggleShowingPopup, showingPopup, popup, popupAnchor} = Kb.usePopup(attachTo => (
38+
<InfoPanelMenu
39+
attachTo={attachTo}
40+
floatingMenuContainerStyle={styles.floatingMenuContainerStyle}
41+
onHidden={toggleShowingPopup}
42+
hasHeader={false}
43+
isSmallTeam={isSmallTeam}
44+
conversationIDKey={conversationIDKey}
45+
visible={showingPopup}
46+
/>
47+
))
48+
3649
return (
3750
<Kb.Box2 direction="vertical" fullWidth={true} gap="small">
3851
<Kb.Box2 direction="horizontal" style={styles.smallContainer} fullWidth={true}>
39-
<InfoPanelMenu
40-
attachTo={getAttachmentRef}
41-
floatingMenuContainerStyle={styles.floatingMenuContainerStyle}
42-
onHidden={toggleShowingMenu}
43-
hasHeader={false}
44-
isSmallTeam={isSmallTeam}
45-
conversationIDKey={conversationIDKey}
46-
visible={showingMenu}
47-
/>
52+
{popup}
4853
{isSmallTeam ? (
4954
<>
5055
<Kb.ConnectedNameWithIcon
@@ -106,8 +111,8 @@ const _TeamHeader = (props: SmallProps) => {
106111
)}
107112
<Kb.Icon
108113
type="iconfont-gear"
109-
onClick={toggleShowingMenu}
110-
ref={setAttachmentRef}
114+
onClick={toggleShowingPopup}
115+
ref={popupAnchor as any}
111116
style={styles.gear}
112117
fontSize={gearIconSize}
113118
/>
@@ -138,7 +143,6 @@ const _TeamHeader = (props: SmallProps) => {
138143
</Kb.Box2>
139144
)
140145
}
141-
const TeamHeader = Kb.OverlayParentHOC(_TeamHeader)
142146

143147
type AdhocHeaderProps = {conversationIDKey: ChatTypes.ConversationIDKey}
144148

‎shared/chat/conversation/info-panel/settings/min-writer-role.tsx‎

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as React from 'react'
21
import * as Chat2Gen from '../../../../actions/chat2-gen'
3-
import * as Container from '../../../../util/container'
4-
import * as Types from '../../../../constants/types/chat2'
52
import * as Constants from '../../../../constants/chat2'
3+
import * as Container from '../../../../util/container'
64
import * as Kb from '../../../../common-adapters'
7-
import * as TeamTypes from '../../../../constants/types/teams'
8-
import * as TeamConstants from '../../../../constants/teams'
5+
import * as React from 'react'
96
import * as Style from '../../../../styles'
7+
import * as TeamConstants from '../../../../constants/teams'
8+
import type * as TeamTypes from '../../../../constants/types/teams'
9+
import type * as Types from '../../../../constants/types/chat2'
1010
import upperFirst from 'lodash/upperFirst'
1111
import {indefiniteArticle} from '../../../../util/string'
1212

@@ -73,51 +73,48 @@ const MinWriterRole = (props: Props) => {
7373
)
7474
}
7575

76-
type DropdownProps = Kb.OverlayParentProps & {
76+
type DropdownProps = {
7777
minWriterRole: TeamTypes.TeamRoleType
7878
items: Kb.MenuItems
7979
saving: boolean
8080
}
8181

82-
const _Dropdown = ({
83-
getAttachmentRef,
84-
items,
85-
minWriterRole,
86-
saving,
87-
setAttachmentRef,
88-
showingMenu,
89-
toggleShowingMenu,
90-
}: DropdownProps) => (
91-
<>
92-
<Kb.ClickableBox
93-
style={styles.dropdown}
94-
ref={Style.isMobile ? null : setAttachmentRef}
95-
onClick={toggleShowingMenu}
96-
underlayColor={Style.globalColors.white_40}
97-
>
98-
<Kb.Box2 direction="horizontal" style={styles.label}>
99-
<Kb.Text type="BodySemibold">{upperFirst(minWriterRole)}</Kb.Text>
100-
</Kb.Box2>
101-
<Kb.Icon type="iconfont-caret-down" inheritColor={true} fontSize={7} sizeType="Tiny" />
102-
</Kb.ClickableBox>
82+
const Dropdown = (p: DropdownProps) => {
83+
const {items, minWriterRole, saving} = p
84+
const {toggleShowingPopup, showingPopup, popup, popupAnchor} = Kb.usePopup(attachTo => (
10385
<Kb.FloatingMenu
104-
attachTo={getAttachmentRef}
86+
attachTo={attachTo}
10587
closeOnSelect={true}
106-
visible={showingMenu}
88+
visible={showingPopup}
10789
items={items}
108-
onHidden={toggleShowingMenu}
90+
onHidden={toggleShowingPopup}
10991
position="top center"
11092
positionFallbacks={['bottom center']}
11193
/>
112-
<Kb.SaveIndicator
113-
saving={saving}
114-
style={styles.saveIndicator}
115-
minSavingTimeMs={300}
116-
savedTimeoutMs={2500}
117-
/>
118-
</>
119-
)
120-
const Dropdown = Kb.OverlayParentHOC(_Dropdown)
94+
))
95+
return (
96+
<>
97+
<Kb.ClickableBox
98+
style={styles.dropdown}
99+
ref={Style.isMobile ? null : popupAnchor}
100+
onClick={toggleShowingPopup}
101+
underlayColor={Style.globalColors.white_40}
102+
>
103+
<Kb.Box2 direction="horizontal" style={styles.label}>
104+
<Kb.Text type="BodySemibold">{upperFirst(minWriterRole)}</Kb.Text>
105+
</Kb.Box2>
106+
<Kb.Icon type="iconfont-caret-down" inheritColor={true} fontSize={7} sizeType="Tiny" />
107+
</Kb.ClickableBox>
108+
{popup}
109+
<Kb.SaveIndicator
110+
saving={saving}
111+
style={styles.saveIndicator}
112+
minSavingTimeMs={300}
113+
savedTimeoutMs={2500}
114+
/>
115+
</>
116+
)
117+
}
121118

122119
const Display = ({minWriterRole}: {minWriterRole: TeamTypes.TeamRoleType}) => (
123120
<Kb.Text type="BodySmall">

0 commit comments

Comments
 (0)