Skip to content

Commit 4ab6c2f

Browse files
Veselina RadevaNathanWalker
Veselina Radeva
authored andcommitted
docs: update issue template
1 parent 26ad2d6 commit 4ab6c2f

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

Diff for: nativescript-angular/router/ns-location-strategy.ts

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from "@angular/core";
22
import { LocationStrategy } from "@angular/common";
33
import { DefaultUrlSerializer, UrlSegmentGroup, UrlTree } from "@angular/router";
4-
import { routerLog } from "../trace";
4+
import { routerLog, routerError } from "../trace";
55
import { NavigationTransition, Frame } from "tns-core-modules/ui/frame";
66
import { isPresent } from "../lang-facade";
77
import { FrameService } from "../platform-providers";
@@ -286,10 +286,11 @@ export class NSLocationStrategy extends LocationStrategy {
286286

287287
// Methods for syncing with page navigation in PageRouterOutlet
288288
public _beginBackPageNavigation(name: string, frame: Frame) {
289-
routerLog("NSLocationStrategy.startGoBack()");
290289
if (this._isPageNavigationBack) {
291-
throw new Error("Calling startGoBack while going back.");
290+
routerError("Attempted to call startGoBack while going back.");
291+
return;
292292
}
293+
routerLog("NSLocationStrategy.startGoBack()");
293294
this._isPageNavigationBack = true;
294295

295296
let { cachedFrame } = this.frameService.findFrame(frame);
@@ -302,10 +303,11 @@ export class NSLocationStrategy extends LocationStrategy {
302303
}
303304

304305
public _finishBackPageNavigation() {
305-
routerLog("NSLocationStrategy.finishBackPageNavigation()");
306306
if (!this._isPageNavigationBack) {
307-
throw new Error("Calling endGoBack while not going back.");
307+
routerError("Attempted to call endGoBack while not going back.");
308+
return;
308309
}
310+
routerLog("NSLocationStrategy.finishBackPageNavigation()");
309311
this._isPageNavigationBack = false;
310312
}
311313

@@ -314,33 +316,35 @@ export class NSLocationStrategy extends LocationStrategy {
314316
}
315317

316318
public _beginModalNavigation(frame: Frame): void {
317-
routerLog("NSLocationStrategy._beginModalNavigation()");
319+
routerLog("NSLocationStrategy._beginModalNavigation()");
318320

319-
let { cachedFrameRootOutlet } = this.frameService.findFrame(frame);
321+
let { cachedFrameRootOutlet } = this.frameService.findFrame(frame);
320322

321-
const lastState = this.peekState(cachedFrameRootOutlet || this.currentOutlet);
323+
const lastState = this.peekState(cachedFrameRootOutlet || this.currentOutlet);
322324

323-
if (lastState) {
324-
lastState.isModalNavigation = true;
325-
}
325+
if (lastState) {
326+
lastState.isModalNavigation = true;
327+
}
326328

327-
this._isModalNavigation = true;
328-
}
329+
this._isModalNavigation = true;
330+
}
329331

330332
public _beginCloseModalNavigation(): void {
331-
routerLog("NSLocationStrategy.startCloseModal()");
332333
if (this._isModalClosing) {
333-
throw new Error("Calling startCloseModal while closing modal.");
334+
routerError("Attempted to call startCloseModal while closing modal.");
335+
return;
334336
}
337+
routerLog("NSLocationStrategy.startCloseModal()");
335338
this._isModalClosing = true;
336339
}
337340

338341
public _finishCloseModalNavigation() {
339-
routerLog("NSLocationStrategy.finishCloseModalNavigation()");
340342
if (!this._isModalClosing) {
341-
throw new Error("Calling startCloseModal while not closing modal.");
343+
routerError("Attempted to call startCloseModal while not closing modal.");
344+
return;
342345
}
343346

347+
routerLog("NSLocationStrategy.finishCloseModalNavigation()");
344348
this._isModalNavigation = false;
345349
this._isModalClosing = false;
346350
}

Diff for: nativescript-angular/router/page-router-outlet.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function routeToString(activatedRoute: ActivatedRoute | ActivatedRouteSnapshot):
102102
return activatedRoute.pathFromRoot.join("->");
103103
}
104104

105+
const routeTransitionWarning = "This could be due to route transition timing and could be ignored.";
106+
105107
@Directive({ selector: "page-router-outlet" }) // tslint:disable-line:directive-selector
106108
export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:directive-class-suffix
107109
private activated: ComponentRef<any> | null = null;
@@ -126,14 +128,16 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
126128

127129
get component(): Object {
128130
if (!this.activated) {
129-
throw new Error("Outlet is not activated");
131+
log("Outlet is not activated");
132+
return;
130133
}
131134

132135
return this.activated.instance;
133136
}
134137
get activatedRoute(): ActivatedRoute {
135138
if (!this.activated) {
136-
throw new Error("Outlet is not activated");
139+
log("Outlet is not activated");
140+
return;
137141
}
138142

139143
return this._activatedRoute;
@@ -173,8 +177,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
173177

174178
deactivate(): void {
175179
if (!this.locationStrategy._isPageNavigatingBack()) {
176-
throw new Error("Currently not in page back navigation" +
177-
" - component should be detached instead of deactivated.");
180+
log("Currently not in page back navigation" +
181+
" - component should be detached instead of deactivated." + routeTransitionWarning);
182+
return;
178183
}
179184

180185
log("PageRouterOutlet.deactivate() while going back - should destroy");
@@ -197,7 +202,8 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
197202
*/
198203
detach(): ComponentRef<any> {
199204
if (!this.isActivated) {
200-
throw new Error("Outlet is not activated");
205+
log("Outlet is not activated");
206+
return;
201207
}
202208

203209
log("PageRouterOutlet.detach() - " + routeToString(this._activatedRoute));
@@ -232,7 +238,8 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
232238
resolver: ComponentFactoryResolver | null): void {
233239

234240
if (this.locationStrategy._isPageNavigatingBack()) {
235-
throw new Error("Currently in page back navigation - component should be reattached instead of activated.");
241+
log("Currently in page back navigation - component should be reattached instead of activated. " + routeTransitionWarning);
242+
this.locationStrategy._finishBackPageNavigation();
236243
}
237244

238245
log("PageRouterOutlet.activateWith() - " + routeToString(activatedRoute));

Diff for: nativescript-angular/trace.ts

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export function routerLog(message: string): void {
2828
write(message, routerTraceCategory);
2929
}
3030

31+
export function routerError(message: string): void {
32+
write(message, routerTraceCategory, messageType.error);
33+
}
34+
3135
export function routeReuseStrategyLog(message: string): void {
3236
write(message, routeReuseStrategyTraceCategory);
3337
}

0 commit comments

Comments
 (0)