From 341462eadbd722346d3e46597186e94857bf0fae Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 24 Aug 2022 11:49:19 -0300 Subject: [PATCH] fix: patch showModal call in zone --- packages/zone-js/dist/events.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/zone-js/dist/events.ts b/packages/zone-js/dist/events.ts index 5250e3e..824c5b6 100644 --- a/packages/zone-js/dist/events.ts +++ b/packages/zone-js/dist/events.ts @@ -47,4 +47,23 @@ Zone.__load_patch('nativescript_dispatchToMainThread', (global, zone, api) => { ); }); +Zone.__load_patch('nativescript_showModal', (global, zone, api) => { + api.patchMethod( + View.prototype, + 'showModal', + (delegate, delegateName, name) => + function (self, args) { + if (args.length === 2) { + const options = args[1]; + if (options.closeCallback) { + options.closeCallback = Zone.current.wrap(options.closeCallback, 'NS showModal patch'); + } + } else if (args.length > 3) { + args[3] = Zone.current.wrap(args[3], 'NS showModal patch'); + } + return delegate.apply(self, args); + } + ); +}); + //! queueMacroTask should never be patched! We should consider it as a low level API to queue macroTasks which will be patched separately by other patches.