From a86d41e7dbf3285e072270b1d6dca2cd4c6760c7 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Mon, 14 May 2018 18:11:02 +0300 Subject: [PATCH] fix(android): fix sporadic issue with transition cleanup logic called twice (#5805) --- .../ui/frame/fragment.transitions.android.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tns-core-modules/ui/frame/fragment.transitions.android.ts b/tns-core-modules/ui/frame/fragment.transitions.android.ts index 8ee6eefa5..584fc9f16 100644 --- a/tns-core-modules/ui/frame/fragment.transitions.android.ts +++ b/tns-core-modules/ui/frame/fragment.transitions.android.ts @@ -695,6 +695,14 @@ function addNativeTransitionListener(entry: ExpandedEntry, nativeTransition: and function transitionOrAnimationCompleted(entry: ExpandedEntry): void { const frameId = entry.frameId; const entries = waitingQueue.get(frameId); + // https://github.com/NativeScript/NativeScript/issues/5759 + // https://github.com/NativeScript/NativeScript/issues/5780 + // transitionOrAnimationCompleted fires again (probably bug in android) + // NOTE: we cannot reproduce this issue so this is a blind fix + if (!entries) { + return; + } + entries.delete(entry); if (entries.size === 0) { const frame = entry.resolvedPage.frame; @@ -707,7 +715,7 @@ function transitionOrAnimationCompleted(entry: ExpandedEntry): void { let current = frame.isCurrent(entry) ? previousCompletedAnimationEntry : entry; current = current || entry; // Will be null if Frame is shown modally... - // AnimationCompleted fires again (probably bug in android). + // transitionOrAnimationCompleted fires again (probably bug in android). if (current) { const isBack = frame._isBack; setTimeout(() => frame.setCurrent(current, isBack));