-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small logic cleanups #3451
Small logic cleanups #3451
Changes from all commits
d7c7cab
7af74dc
deb4b27
121840c
c9831f9
e98ebae
84d5ceb
8dfc085
bebdc8f
4042122
9f706f0
082d63d
ef11e61
7982c8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,24 +33,25 @@ export function Outer({ | |
const t = useTheme() | ||
const {gtMobile} = useBreakpoints() | ||
const [isOpen, setIsOpen] = React.useState(false) | ||
const [isVisible, setIsVisible] = React.useState(true) | ||
const {setDialogIsOpen} = useDialogStateControlContext() | ||
|
||
const open = React.useCallback(() => { | ||
setIsOpen(true) | ||
setDialogIsOpen(control.id, true) | ||
setIsOpen(true) | ||
}, [setIsOpen, setDialogIsOpen, control.id]) | ||
|
||
const close = React.useCallback<DialogControlProps['close']>( | ||
cb => { | ||
setDialogIsOpen(control.id, false) | ||
setIsVisible(false) | ||
setIsOpen(false) | ||
setIsVisible(true) | ||
Comment on lines
-47
to
-49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also can't see a visual difference after removing this in the web version, so unsure if we need it. We're conditionally rendering in the dialog once There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. State calls during events should be batched so I'm not sure there'd be a difference either way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ya know what, this is leftovers from an exit animation we removed, def safe to remove |
||
|
||
try { | ||
if (cb && typeof cb === 'function') { | ||
cb() | ||
// This timeout ensures that the callback runs at the same time as it would on native. I.e. | ||
// console.log('Step 1') -> close(() => console.log('Step 3')) -> console.log('Step 2') | ||
// This should always output 'Step 1', 'Step 2', 'Step 3', but without the timeout it would output | ||
// 'Step 1', 'Step 3', 'Step 2'. | ||
setTimeout(cb) | ||
Comment on lines
+50
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good callout on this one, |
||
} | ||
} catch (e: any) { | ||
logger.error(`Dialog closeCallback failed`, { | ||
|
@@ -113,17 +114,15 @@ export function Outer({ | |
gtMobile ? a.p_lg : a.p_md, | ||
{overflowY: 'auto'}, | ||
]}> | ||
{isVisible && ( | ||
<Animated.View | ||
estrattonbailey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
entering={FadeIn.duration(150)} | ||
// exiting={FadeOut.duration(150)} | ||
style={[ | ||
web(a.fixed), | ||
a.inset_0, | ||
{opacity: 0.8, backgroundColor: t.palette.black}, | ||
]} | ||
/> | ||
)} | ||
<Animated.View | ||
entering={FadeIn.duration(150)} | ||
// exiting={FadeOut.duration(150)} | ||
style={[ | ||
web(a.fixed), | ||
a.inset_0, | ||
{opacity: 0.8, backgroundColor: t.palette.black}, | ||
]} | ||
/> | ||
|
||
<View | ||
style={[ | ||
|
@@ -135,7 +134,7 @@ export function Outer({ | |
minHeight: web('calc(90vh - 36px)') || undefined, | ||
}, | ||
]}> | ||
{isVisible ? children : null} | ||
estrattonbailey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{children} | ||
</View> | ||
</View> | ||
</TouchableWithoutFeedback> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling this
onCloseAnimationComplete
I think gives us a better sense of the purpose of this function. Too many things calledclose
andonClose
gets a bit confusing I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To expand on why this is necessary:
On some lower end devices, if we try to do all of this at the same time as
sheet.current?.close()
, there is a significant performance drop. On Android, I can make the FPS drop to zero just by closing the sheet and removing a post from the feed at the same time.Instead, we want to call
sheet.current?.close()
, and let theBottomSheet
component decide when to callonCloseAnimationComplete
, ensuring a smooth transition.