diff options
| author | Oskar <oskar@mullvad.net> | 2025-09-15 15:02:04 +0200 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2025-10-01 13:19:43 +0200 |
| commit | 86ef4c889f3b03a1b4e174ae27dce640af1b1649 (patch) | |
| tree | b9e2b21bf8dbc79324215a19cf1007f5d2b6d16a | |
| parent | f89775b79f7ce79cf1c8b0cb58d6212d4f9c09fa (diff) | |
| download | mullvadvpn-86ef4c889f3b03a1b4e174ae27dce640af1b1649.tar.xz mullvadvpn-86ef4c889f3b03a1b4e174ae27dce640af1b1649.zip | |
Remove flushSync call for view transitions
| -rw-r--r-- | desktop/packages/mullvad-vpn/src/renderer/lib/transition-hooks.ts | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/lib/transition-hooks.ts b/desktop/packages/mullvad-vpn/src/renderer/lib/transition-hooks.ts index e48048c058..cf8dad0e6e 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/lib/transition-hooks.ts +++ b/desktop/packages/mullvad-vpn/src/renderer/lib/transition-hooks.ts @@ -1,6 +1,5 @@ import { Location } from 'history'; import { useCallback, useEffect, useRef, useState } from 'react'; -import { flushSync } from 'react-dom'; import { ViewTransition } from '../../../types/global'; import { LocationState } from '../../shared/ipc-types'; @@ -47,24 +46,22 @@ export function useViewTransitions(onTransition?: () => void): Location<Location return; } - flushSync(() => { - viewTransitionRef.current = document.startViewTransition(() => { - updateView(location); - }); + viewTransitionRef.current = document.startViewTransition(() => { + updateView(location); + }); - void viewTransitionRef.current.ready.then(() => animateNavigation(transition)); - void viewTransitionRef.current.finished.then(() => { - const queueLocation = queuedLocationRef.current; + void viewTransitionRef.current.ready.then(() => animateNavigation(transition)); + void viewTransitionRef.current.finished.then(() => { + const queueLocation = queuedLocationRef.current; - delete viewTransitionRef.current; - delete queuedLocationRef.current; + delete viewTransitionRef.current; + delete queuedLocationRef.current; - if (queueLocation) { - transitionToView(queueLocation.location, queueLocation.transition); - } else { - onTransition?.(); - } - }); + if (queueLocation) { + transitionToView(queueLocation.location, queueLocation.transition); + } else { + onTransition?.(); + } }); }, ); |
