diff options
author | dan <dan.abramov@gmail.com> | 2023-10-13 20:10:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-13 20:10:15 +0100 |
commit | f447eaa6692c46921bf1124e2cfe2f030f0cc08d (patch) | |
tree | 3f903f2b9fbebdefe2a7cfbbaed52b274707ca4c /src/Navigation.tsx | |
parent | d5ccbd76d5ffc9280f0109138f608b94bee0aadf (diff) | |
download | voidsky-f447eaa6692c46921bf1124e2cfe2f030f0cc08d.tar.zst |
Fix profile preview jump (#1693)
* Add top inset for profile preview to match target screen * Avoid flicker by waiting for profile screen navigation * Fix glimmer to align with the content * A more reliable (but non-scientific) fix for the flash * Lower the timeout
Diffstat (limited to 'src/Navigation.tsx')
-rw-r--r-- | src/Navigation.tsx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 97612c9ec..e1d5e76aa 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -483,9 +483,21 @@ function navigate<K extends keyof AllNavigatorParams>( params?: AllNavigatorParams[K], ) { if (navigationRef.isReady()) { - // @ts-ignore I dont know what would make typescript happy but I have a life -prf - navigationRef.navigate(name, params) + return Promise.race([ + new Promise<void>(resolve => { + const handler = () => { + resolve() + navigationRef.removeListener('state', handler) + } + navigationRef.addListener('state', handler) + + // @ts-ignore I dont know what would make typescript happy but I have a life -prf + navigationRef.navigate(name, params) + }), + timeout(1e3), + ]) } + return Promise.resolve() } function resetToTab(tabName: 'HomeTab' | 'SearchTab' | 'NotificationsTab') { |