Skip to content

Commit 51a61f1

Browse files
authored
Merge branch 'master' into sis0k0/remove-short-imports-resolution
2 parents 685ddca + f12000e commit 51a61f1

File tree

5 files changed

+54
-12
lines changed

5 files changed

+54
-12
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="7.2.3"></a>
2+
## [7.2.3](https://github.com/NativeScript/nativescript-angular/compare/7.2.2...7.2.3) (2019-03-14)
3+
4+
5+
### Bug Fixes
6+
7+
* **location-strategy:** crash on going back with router-outlet after closing modal ([#1748](https://github.com/NativeScript/nativescript-angular/issues/1748)) ([0ed7de6](https://github.com/NativeScript/nativescript-angular/commit/0ed7de6))
8+
9+
10+
111
<a name="7.2.2"></a>
212
## [7.2.2](https://github.com/NativeScript/nativescript-angular/compare/7.2.1...7.2.2) (2019-02-19)
313

nativescript-angular/platform-common.ts

+24
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
on,
3434
launchEvent,
3535
LaunchEventData,
36+
exitEvent,
37+
ApplicationEventData,
3638
} from "tns-core-modules/application";
3739
import { TextView } from "tns-core-modules/ui/text-view";
3840

@@ -255,7 +257,29 @@ export class NativeScriptPlatformRef extends PlatformRef {
255257
args.root = rootContent;
256258
}
257259
);
260+
const exitCallback = profile(
261+
"nativescript-angular/platform-common.exitCallback", (args: ApplicationEventData) => {
262+
const androidActivity = args.android;
263+
if (androidActivity && !androidActivity.isFinishing()) {
264+
// Exit event was triggered as a part of a restart of the app.
265+
return;
266+
}
267+
268+
const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null;
269+
if (lastModuleRef) {
270+
// Make sure the module is only destroyed once
271+
lastBootstrappedModule = null;
272+
273+
lastModuleRef.destroy();
274+
}
275+
276+
if (!autoCreateFrame) {
277+
rootContent = null;
278+
}
279+
}
280+
);
258281
on(launchEvent, launchCallback);
282+
on(exitEvent, exitCallback);
259283

260284
applicationRun();
261285
}

nativescript-angular/router/ns-platform-location.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { routerLog, isLogEnabled } from "../trace";
66
@Injectable()
77
export class NativescriptPlatformLocation extends PlatformLocation {
88

9-
constructor(private locationStartegy: NSLocationStrategy) {
9+
constructor(private locationStrategy: NSLocationStrategy) {
1010
super();
1111
if (isLogEnabled()) {
1212
routerLog("NativescriptPlatformLocation.constructor()");
@@ -18,7 +18,7 @@ export class NativescriptPlatformLocation extends PlatformLocation {
1818
}
1919

2020
onPopState(fn: LocationChangeListener): void {
21-
this.locationStartegy.onPopState(fn);
21+
this.locationStrategy.onPopState(fn);
2222
}
2323

2424
onHashChange(_fn: LocationChangeListener): void {
@@ -31,25 +31,25 @@ export class NativescriptPlatformLocation extends PlatformLocation {
3131
return "";
3232
}
3333
get pathname(): string {
34-
return this.locationStartegy.path();
34+
return this.locationStrategy.path();
3535
}
3636
set pathname(_newPath: string) {
3737
throw new Error("NativescriptPlatformLocation set pathname - not implemented");
3838
}
3939

4040
pushState(state: any, title: string, url: string): void {
41-
this.locationStartegy.pushState(state, title, url, null);
41+
this.locationStrategy.pushState(state, title, url, null);
4242
}
4343

4444
replaceState(state: any, title: string, url: string): void {
45-
this.locationStartegy.replaceState(state, title, url, null);
45+
this.locationStrategy.replaceState(state, title, url, null);
4646
}
4747

4848
forward(): void {
4949
throw new Error("NativescriptPlatformLocation.forward() - not implemented");
5050
}
5151

5252
back(): void {
53-
this.locationStartegy.back();
53+
this.locationStrategy.back();
5454
}
5555
}

nativescript-angular/router/page-router-outlet.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,19 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
352352
// Add it to the new page
353353
page.content = componentView;
354354

355-
page.on(Page.navigatedFromEvent, (<any>global).Zone.current.wrap((args: NavigatedData) => {
355+
const navigatedFromCallback = (<any>global).Zone.current.wrap((args: NavigatedData) => {
356356
if (args.isBackNavigation) {
357357
this.locationStrategy._beginBackPageNavigation(this.frame);
358358
this.locationStrategy.back(null, this.frame);
359359
}
360-
}));
360+
});
361+
page.on(Page.navigatedFromEvent, navigatedFromCallback);
362+
componentRef.onDestroy(() => {
363+
if (page) {
364+
page.off(Page.navigatedFromEvent, navigatedFromCallback);
365+
page = null;
366+
}
367+
});
361368

362369
const navOptions = this.locationStrategy._beginPageNavigation(this.frame);
363370

@@ -367,14 +374,15 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
367374
if (this.outlet) {
368375
this.routeReuseStrategy.clearCache(this.outlet.outletKeys[0]);
369376
}
370-
page.off(Page.navigatedToEvent, clearCallback);
371377
});
372378

373-
page.on(Page.navigatedToEvent, clearCallback);
379+
page.once(Page.navigatedToEvent, clearCallback);
374380
}
375381

376382
this.frame.navigate({
377-
create: () => { return page; },
383+
create() {
384+
return page;
385+
},
378386
clearHistory: navOptions.clearHistory,
379387
animated: navOptions.animated,
380388
transition: navOptions.transition

nativescript-angular/router/router.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const NS_ROUTER_PROVIDERS = [
2929
},
3030
{ provide: LocationStrategy, useExisting: NSLocationStrategy },
3131
NativescriptPlatformLocation,
32-
{ provide: PlatformLocation, useClass: NativescriptPlatformLocation },
32+
{ provide: PlatformLocation, useExisting: NativescriptPlatformLocation },
3333
RouterExtensions,
3434
NSRouteReuseStrategy,
3535
{ provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy },

0 commit comments

Comments
 (0)