Skip to content

Commit b3e136a

Browse files
Veselina RadevaNathanWalker
Veselina Radeva
authored andcommitted
docs: update issue template
1 parent 801f96b commit b3e136a

File tree

2 files changed

+42
-31
lines changed

2 files changed

+42
-31
lines changed

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

+29-25
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 as log } from "../trace";
55
import { NavigationTransition } from "tns-core-modules/ui/frame";
66
import { isPresent } from "../lang-facade";
77
import { FrameService } from "../platform-providers";
@@ -42,7 +42,7 @@ export class NSLocationStrategy extends LocationStrategy {
4242

4343
constructor(private frameService: FrameService) {
4444
super();
45-
routerLog("NSLocationStrategy.constructor()");
45+
log("NSLocationStrategy.constructor()");
4646
}
4747

4848
path(): string {
@@ -67,17 +67,17 @@ export class NSLocationStrategy extends LocationStrategy {
6767

6868
const urlSerializer = new DefaultUrlSerializer();
6969
const url = urlSerializer.serialize(tree);
70-
routerLog("NSLocationStrategy.path(): " + url);
70+
log("NSLocationStrategy.path(): " + url);
7171
return url;
7272
}
7373

7474
prepareExternalUrl(internal: string): string {
75-
routerLog("NSLocationStrategy.prepareExternalUrl() internal: " + internal);
75+
log("NSLocationStrategy.prepareExternalUrl() internal: " + internal);
7676
return internal;
7777
}
7878

7979
pushState(state: any, title: string, url: string, queryParams: string): void {
80-
routerLog("NSLocationStrategy.pushState state: " +
80+
log("NSLocationStrategy.pushState state: " +
8181
`${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
8282
this.pushStateInternal(state, title, url, queryParams);
8383
}
@@ -130,7 +130,7 @@ export class NSLocationStrategy extends LocationStrategy {
130130
replaceState(state: any, title: string, url: string, queryParams: string): void {
131131
const states = this.statesByOutlet[this.currentOutlet];
132132
if (states && states.length > 0) {
133-
routerLog("NSLocationStrategy.replaceState changing existing state: " +
133+
log("NSLocationStrategy.replaceState changing existing state: " +
134134
`${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
135135

136136
const tree = this.currentUrlTree;
@@ -149,7 +149,7 @@ export class NSLocationStrategy extends LocationStrategy {
149149
});
150150
}
151151
} else {
152-
routerLog("NSLocationStrategy.replaceState pushing new state: " +
152+
log("NSLocationStrategy.replaceState pushing new state: " +
153153
`${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
154154
this.pushStateInternal(state, title, url, queryParams);
155155
}
@@ -186,7 +186,7 @@ export class NSLocationStrategy extends LocationStrategy {
186186
}
187187
}
188188

189-
routerLog("NSLocationStrategy.back() while closing modal. States popped: " + count);
189+
log("NSLocationStrategy.back() while closing modal. States popped: " + count);
190190

191191
if (state) {
192192
this.callPopState(state, true);
@@ -203,19 +203,19 @@ export class NSLocationStrategy extends LocationStrategy {
203203
count++;
204204
}
205205

206-
routerLog("NSLocationStrategy.back() while navigating back. States popped: " + count);
206+
log("NSLocationStrategy.back() while navigating back. States popped: " + count);
207207
this.callPopState(state, true);
208208
} else {
209209
let state = this.peekState(this.currentOutlet);
210210
if (state.isPageNavigation) {
211211
// This was a page navigation - so navigate through frame.
212-
routerLog("NSLocationStrategy.back() while not navigating back but top" +
212+
log("NSLocationStrategy.back() while not navigating back but top" +
213213
" state is page - will call frame.goBack()");
214214
const frame = this.frameService.getFrame();
215215
frame.goBack();
216216
} else {
217217
// Nested navigation - just pop the state
218-
routerLog("NSLocationStrategy.back() while not navigating back but top" +
218+
log("NSLocationStrategy.back() while not navigating back but top" +
219219
" state is not page - just pop");
220220

221221
this.callPopState(this.statesByOutlet[this.currentOutlet].pop(), true);
@@ -229,12 +229,12 @@ export class NSLocationStrategy extends LocationStrategy {
229229
}
230230

231231
onPopState(fn: (_: any) => any): void {
232-
routerLog("NSLocationStrategy.onPopState");
232+
log("NSLocationStrategy.onPopState");
233233
this.popStateCallbacks.push(fn);
234234
}
235235

236236
getBaseHref(): string {
237-
routerLog("NSLocationStrategy.getBaseHref()");
237+
log("NSLocationStrategy.getBaseHref()");
238238
return "";
239239
}
240240

@@ -284,19 +284,21 @@ export class NSLocationStrategy extends LocationStrategy {
284284

285285
// Methods for syncing with page navigation in PageRouterOutlet
286286
public _beginBackPageNavigation(name: string) {
287-
routerLog("NSLocationStrategy.startGoBack()");
288287
if (this._isPageNavigationBack) {
289-
throw new Error("Calling startGoBack while going back.");
288+
log("Warn: Attempted to call startGoBack while going back. Ignoring.");
289+
return;
290290
}
291+
log("NSLocationStrategy.startGoBack()");
291292
this._isPageNavigationBack = true;
292293
this.currentOutlet = name;
293294
}
294295

295296
public _finishBackPageNavigation() {
296-
routerLog("NSLocationStrategy.finishBackPageNavigation()");
297297
if (!this._isPageNavigationBack) {
298-
throw new Error("Calling endGoBack while not going back.");
298+
log("Warn: Attempted to call endGoBack while not going back. Ignoring.");
299+
return;
299300
}
301+
log("NSLocationStrategy.finishBackPageNavigation()");
300302
this._isPageNavigationBack = false;
301303
}
302304

@@ -305,7 +307,7 @@ export class NSLocationStrategy extends LocationStrategy {
305307
}
306308

307309
public _beginModalNavigation(): void {
308-
routerLog("NSLocationStrategy._beginModalNavigation()");
310+
log("NSLocationStrategy._beginModalNavigation()");
309311
const lastState = this.peekState(this.currentOutlet);
310312

311313
if (lastState) {
@@ -316,25 +318,27 @@ export class NSLocationStrategy extends LocationStrategy {
316318
}
317319

318320
public _beginCloseModalNavigation(): void {
319-
routerLog("NSLocationStrategy.startCloseModal()");
320321
if (this._isModalClosing) {
321-
throw new Error("Calling startCloseModal while closing modal.");
322+
log("Warn: Attempted to call startCloseModal while closing modal. Ignoring.");
323+
return;
322324
}
325+
log("NSLocationStrategy.startCloseModal()");
323326
this._isModalClosing = true;
324327
}
325328

326329
public _finishCloseModalNavigation() {
327-
routerLog("NSLocationStrategy.finishCloseModalNavigation()");
328330
if (!this._isModalClosing) {
329-
throw new Error("Calling startCloseModal while not closing modal.");
331+
log("Warn: Attempted to call startCloseModal while not closing modal. Ignoring.");
332+
return;
330333
}
331334

335+
log("NSLocationStrategy.finishCloseModalNavigation()");
332336
this._isModalNavigation = false;
333337
this._isModalClosing = false;
334338
}
335339

336340
public _beginPageNavigation(name: string): NavigationOptions {
337-
routerLog("NSLocationStrategy._beginPageNavigation()");
341+
log("NSLocationStrategy._beginPageNavigation()");
338342
const lastState = this.peekState(name);
339343
if (lastState) {
340344
lastState.isPageNavigation = true;
@@ -344,7 +348,7 @@ export class NSLocationStrategy extends LocationStrategy {
344348

345349
const navOptions = this._currentNavigationOptions || defaultNavOptions;
346350
if (navOptions.clearHistory) {
347-
routerLog("NSLocationStrategy._beginPageNavigation clearing states history");
351+
log("NSLocationStrategy._beginPageNavigation clearing states history");
348352
this.statesByOutlet[name] = [lastState];
349353
}
350354

@@ -358,7 +362,7 @@ export class NSLocationStrategy extends LocationStrategy {
358362
animated: isPresent(options.animated) ? options.animated : true,
359363
transition: options.transition
360364
};
361-
routerLog("NSLocationStrategy._setNavigationOptions(" +
365+
log("NSLocationStrategy._setNavigationOptions(" +
362366
`${JSON.stringify(this._currentNavigationOptions)})`);
363367
}
364368

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

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

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

126128
get component(): Object {
127129
if (!this.activated) {
128-
throw new Error("Outlet is not activated");
130+
log("Outlet is not activated");
131+
return;
129132
}
130133

131134
return this.activated.instance;
132135
}
133136
get activatedRoute(): ActivatedRoute {
134137
if (!this.activated) {
135-
throw new Error("Outlet is not activated");
138+
log("Outlet is not activated");
139+
return;
136140
}
137141

138142
return this._activatedRoute;
@@ -170,8 +174,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
170174

171175
deactivate(): void {
172176
if (!this.locationStrategy._isPageNavigatingBack()) {
173-
throw new Error("Currently not in page back navigation" +
174-
" - component should be detached instead of deactivated.");
177+
log("Currently not in page back navigation" +
178+
" - component should be detached instead of deactivated." + routeTransitionWarning);
179+
return;
175180
}
176181

177182
log("PageRouterOutlet.deactivate() while going back - should destroy");
@@ -194,7 +199,8 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
194199
*/
195200
detach(): ComponentRef<any> {
196201
if (!this.isActivated) {
197-
throw new Error("Outlet is not activated");
202+
log("Outlet is not activated");
203+
return;
198204
}
199205

200206
log("PageRouterOutlet.detach() - " + routeToString(this._activatedRoute));
@@ -229,7 +235,8 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
229235
resolver: ComponentFactoryResolver | null): void {
230236

231237
if (this.locationStrategy._isPageNavigatingBack()) {
232-
throw new Error("Currently in page back navigation - component should be reattached instead of activated.");
238+
log("Currently in page back navigation - component should be reattached instead of activated. " + routeTransitionWarning);
239+
this.locationStrategy._finishBackPageNavigation();
233240
}
234241

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

0 commit comments

Comments
 (0)