Skip to content

Commit 1b5bfae

Browse files
Veselina RadevaNathanWalker
Veselina Radeva
authored andcommitted
docs: update issue template
1 parent e551df2 commit 1b5bfae

File tree

3 files changed

+51
-53
lines changed

3 files changed

+51
-53
lines changed

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

+34-47
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, 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";
@@ -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

@@ -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+
log("NSLocationStrategy.startGoBack()");
293294
this._isPageNavigationBack = true;
294295

295296
let { cachedFrame } = this.frameService.findFrame(frame);
@@ -302,23 +303,21 @@ 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+
log("NSLocationStrategy.finishBackPageNavigation()");
309311
this._isPageNavigationBack = false;
310312
}
311313

312314
public _isPageNavigatingBack() {
313315
return this._isPageNavigationBack;
314316
}
315317

316-
public _beginModalNavigation(frame: Frame): void {
317-
routerLog("NSLocationStrategy._beginModalNavigation()");
318-
319-
let { cachedFrameRootOutlet } = this.frameService.findFrame(frame);
320-
321-
const lastState = this.peekState(cachedFrameRootOutlet || this.currentOutlet);
318+
public _beginModalNavigation(): void {
319+
log("NSLocationStrategy._beginModalNavigation()");
320+
const lastState = this.peekState(this.currentOutlet);
322321

323322
if (lastState) {
324323
lastState.isModalNavigation = true;
@@ -328,48 +327,36 @@ export class NSLocationStrategy extends LocationStrategy {
328327
}
329328

330329
public _beginCloseModalNavigation(): void {
331-
routerLog("NSLocationStrategy.startCloseModal()");
332330
if (this._isModalClosing) {
333-
throw new Error("Calling startCloseModal while closing modal.");
331+
routerError("Attempted to call startCloseModal while closing modal.");
332+
return;
334333
}
334+
log("NSLocationStrategy.startCloseModal()");
335335
this._isModalClosing = true;
336336
}
337337

338338
public _finishCloseModalNavigation() {
339-
routerLog("NSLocationStrategy.finishCloseModalNavigation()");
340339
if (!this._isModalClosing) {
341-
throw new Error("Calling startCloseModal while not closing modal.");
340+
routerError("Attempted to call startCloseModal while not closing modal.");
341+
return;
342342
}
343343

344+
log("NSLocationStrategy.finishCloseModalNavigation()");
344345
this._isModalNavigation = false;
345346
this._isModalClosing = false;
346347
}
347348

348-
public _beginPageNavigation(name: string, frame: Frame): NavigationOptions {
349-
routerLog("NSLocationStrategy._beginPageNavigation()");
350-
351-
let { cachedFrame } = this.frameService.findFrame(frame);
352-
353-
if (cachedFrame) {
354-
this.currentOutlet = cachedFrame.rootOutlet;
355-
} else {
356-
// Changing the current outlet only if navigating in non-cached root outlet.
357-
if (!this.frameService.containsOutlet(name) && this.statesByOutlet[name] /* ensure root outlet exists */) {
358-
this.currentOutlet = name;
359-
}
360-
361-
this.frameService.addFrame(frame, name, this.currentOutlet);
362-
}
363-
364-
const lastState = this.peekState(this.currentOutlet);
349+
public _beginPageNavigation(name: string): NavigationOptions {
350+
log("NSLocationStrategy._beginPageNavigation()");
351+
const lastState = this.peekState(name);
365352
if (lastState) {
366353
lastState.isPageNavigation = true;
367354
}
368355

369356
const navOptions = this._currentNavigationOptions || defaultNavOptions;
370357
if (navOptions.clearHistory) {
371-
routerLog("NSLocationStrategy._beginPageNavigation clearing states history");
372-
this.statesByOutlet[this.currentOutlet] = [lastState];
358+
log("NSLocationStrategy._beginPageNavigation clearing states history");
359+
this.statesByOutlet[name] = [lastState];
373360
}
374361

375362
this._currentNavigationOptions = undefined;
@@ -382,7 +369,7 @@ export class NSLocationStrategy extends LocationStrategy {
382369
animated: isPresent(options.animated) ? options.animated : true,
383370
transition: options.transition
384371
};
385-
routerLog("NSLocationStrategy._setNavigationOptions(" +
372+
log("NSLocationStrategy._setNavigationOptions(" +
386373
`${JSON.stringify(this._currentNavigationOptions)})`);
387374
}
388375

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)