From 958303118b6cee5f3640571335f19169bde95658 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 9 Mar 2025 03:01:14 +0200 Subject: [PATCH 1/3] fix: page unmount type error --- src/plugins/navigation.ts | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/plugins/navigation.ts b/src/plugins/navigation.ts index 5bea2885..55423830 100644 --- a/src/plugins/navigation.ts +++ b/src/plugins/navigation.ts @@ -1,4 +1,10 @@ -import { Frame, NavigationEntry, Page } from '@nativescript/core'; +import { + EventData, + Frame, + NavigationEntry, + Page, + ViewBase, +} from '@nativescript/core'; import { App, Component, Ref, nextTick, unref } from '@vue/runtime-core'; import { NSVElement, NSVRoot } from '../dom'; import { CreateNativeViewProps, createNativeView } from '../runtimeHelpers'; @@ -75,19 +81,17 @@ export function $navigateTo

( const root = new NSVRoot(); let isReloading = false; - const attachDisposeCallback = (page: Page) => { - const dispose = page.disposeNativeView; + const disposeCallback = (args: EventData) => { + const page = args.object as Page; - page.disposeNativeView = () => { - dispose.call(page); - - // if we are reloading, don't unmount the view, as the reload will unmount/remount it. - if (!isReloading) { - view.unmount(); - view = null; - } - }; + // if we are reloading, don't unmount the view, as the reload will unmount/remount it. + if (!isReloading && view) { + page.off(ViewBase.disposeNativeViewEvent, disposeCallback); + view.unmount(); + view = null; + } }; + const reloadPage = () => { if (isReloading) { return; @@ -106,7 +110,7 @@ export function $navigateTo

( isReloading = true; view.unmount(); view.mount(root); - attachDisposeCallback(view.nativeView); + view.nativeView.on(ViewBase.disposeNativeViewEvent, disposeCallback); const originalTransition = frame.currentEntry.transition; // replace current page @@ -133,7 +137,7 @@ export function $navigateTo

( }); view.mount(root); - attachDisposeCallback(view.nativeView); + view.nativeView.on(ViewBase.disposeNativeViewEvent, disposeCallback); frame.navigate({ ...options, From 61ef086c04c3ef1688be71fc6d219ce44561412d Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 9 Mar 2025 03:06:01 +0200 Subject: [PATCH 2/3] chore: added an event precaution --- src/plugins/navigation.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/navigation.ts b/src/plugins/navigation.ts index 55423830..110a64bc 100644 --- a/src/plugins/navigation.ts +++ b/src/plugins/navigation.ts @@ -110,6 +110,7 @@ export function $navigateTo

( isReloading = true; view.unmount(); view.mount(root); + view.nativeView.off(ViewBase.disposeNativeViewEvent, disposeCallback); view.nativeView.on(ViewBase.disposeNativeViewEvent, disposeCallback); const originalTransition = frame.currentEntry.transition; From 181da58ed21d72ea89dfc1d7dd984a40f2a1b898 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 9 Mar 2025 03:07:20 +0200 Subject: [PATCH 3/3] chore: added another listener remove call --- src/plugins/navigation.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/navigation.ts b/src/plugins/navigation.ts index 110a64bc..10ed3d58 100644 --- a/src/plugins/navigation.ts +++ b/src/plugins/navigation.ts @@ -138,6 +138,7 @@ export function $navigateTo

( }); view.mount(root); + view.nativeView.off(ViewBase.disposeNativeViewEvent, disposeCallback); view.nativeView.on(ViewBase.disposeNativeViewEvent, disposeCallback); frame.navigate({ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy