mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-10-31 02:27:11 -04:00 
			
		
		
		
	Fixing back navigation to genre or studio
This commit is contained in:
		
							parent
							
								
									ca0898c929
								
							
						
					
					
						commit
						97a57a500d
					
				| @ -34,16 +34,16 @@ const routes: Routes = [ | |||||||
| 		resolve: {items: PageResolver.forResource<LibraryItem>("library/:slug/items", ItemsGridComponent.routeMapper)}, | 		resolve: {items: PageResolver.forResource<LibraryItem>("library/:slug/items", ItemsGridComponent.routeMapper)}, | ||||||
| 		canLoad: [AuthGuard.forPermissions("read")], | 		canLoad: [AuthGuard.forPermissions("read")], | ||||||
| 		canActivate: [AuthGuard.forPermissions("read")], | 		canActivate: [AuthGuard.forPermissions("read")], | ||||||
| 		runGuardsAndResolvers: "always" | 		runGuardsAndResolvers: "always", | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	{path: "genre/:slug", component: ItemsGridComponent, pathMatch: "full", | 	{path: "genre/:slug", component: ItemsGridComponent, | ||||||
| 		resolve: {items: PageResolver.forResource<Show>("shows", ItemsGridComponent.routeMapper, "genres=ctn::slug")}, | 		resolve: {items: PageResolver.forResource<Show>("shows", ItemsGridComponent.routeMapper, "genres=ctn::slug")}, | ||||||
| 		canLoad: [AuthGuard.forPermissions("read")], | 		canLoad: [AuthGuard.forPermissions("read")], | ||||||
| 		canActivate: [AuthGuard.forPermissions("read")], | 		canActivate: [AuthGuard.forPermissions("read")], | ||||||
| 		runGuardsAndResolvers: "always" | 		runGuardsAndResolvers: "always" | ||||||
| 	}, | 	}, | ||||||
| 	{path: "studio/:slug", component: ItemsGridComponent, pathMatch: "full", | 	{path: "studio/:slug", component: ItemsGridComponent, | ||||||
| 		resolve: {items: PageResolver.forResource<Show>("shows", ItemsGridComponent.routeMapper, "studio=:slug")}, | 		resolve: {items: PageResolver.forResource<Show>("shows", ItemsGridComponent.routeMapper, "studio=:slug")}, | ||||||
| 		canLoad: [AuthGuard.forPermissions("read")], | 		canLoad: [AuthGuard.forPermissions("read")], | ||||||
| 		canActivate: [AuthGuard.forPermissions("read")], | 		canActivate: [AuthGuard.forPermissions("read")], | ||||||
|  | |||||||
| @ -51,7 +51,7 @@ export class ItemsGridComponent | |||||||
| 			let selectedGenres: string[] = []; | 			let selectedGenres: string[] = []; | ||||||
| 			if (this.route.snapshot.queryParams.genres?.startsWith("ctn:")) | 			if (this.route.snapshot.queryParams.genres?.startsWith("ctn:")) | ||||||
| 				selectedGenres = this.route.snapshot.queryParams.genres.substr(4).split(','); | 				selectedGenres = this.route.snapshot.queryParams.genres.substr(4).split(','); | ||||||
| 			else if (this.route.snapshot.queryParams.genre != null) | 			else if (this.route.snapshot.queryParams.genres != null) | ||||||
| 				selectedGenres = this.route.snapshot.queryParams.genres.split(','); | 				selectedGenres = this.route.snapshot.queryParams.genres.split(','); | ||||||
| 			if (this.router.url.startsWith("/genre")) | 			if (this.router.url.startsWith("/genre")) | ||||||
| 				selectedGenres.push(this.route.snapshot.params.slug); | 				selectedGenres.push(this.route.snapshot.params.slug); | ||||||
| @ -62,12 +62,13 @@ export class ItemsGridComponent | |||||||
| 		{ | 		{ | ||||||
| 			this.studios = data; | 			this.studios = data; | ||||||
| 			this.filters.studio = this.studios.find(x => x.slug == this.route.snapshot.queryParams.studio | 			this.filters.studio = this.studios.find(x => x.slug == this.route.snapshot.queryParams.studio | ||||||
| 			                                     || x.slug == this.route.snapshot.params.slug); | 			                                             || x.slug == this.route.snapshot.params.slug); | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// TODO support dynamic switching between /genre & /browse & /whatever.
 | 	// TODO disable page refresh when swiching from /browse to /studio to /genre.
 | ||||||
| 	// TODO /collection & /people does not get refreshed data from the provider when using a new filter/sort.
 | 	// TODO /collection & /people does not get refreshed data from the provider when using a new filter/sort.
 | ||||||
|  | 	// TODO add /people to the switch list.
 | ||||||
| 
 | 
 | ||||||
| 	/* | 	/* | ||||||
| 	* /browse           -> /api/items | /api/shows | 	* /browse           -> /api/items | /api/shows | ||||||
| @ -122,7 +123,7 @@ export class ItemsGridComponent | |||||||
| 
 | 
 | ||||||
| 		let param: string = null; | 		let param: string = null; | ||||||
| 		if (isArray && this.filters[category].length > 0) | 		if (isArray && this.filters[category].length > 0) | ||||||
| 			param = `ctn:${this.filters[category].map(x => x.slug).join(',')}`; | 			param = `${this.filters[category].map(x => x.slug).join(',')}`; | ||||||
| 		else if (!isArray && this.filters[category] != null) | 		else if (!isArray && this.filters[category] != null) | ||||||
| 			param = filter.slug; | 			param = filter.slug; | ||||||
| 
 | 
 | ||||||
| @ -134,6 +135,7 @@ export class ItemsGridComponent | |||||||
| 			{ | 			{ | ||||||
| 				this.router.navigate(["genre", this.filters.genres[0].slug], { | 				this.router.navigate(["genre", this.filters.genres[0].slug], { | ||||||
| 					replaceUrl: true, | 					replaceUrl: true, | ||||||
|  | 					queryParams: {[category]: null}, | ||||||
| 					queryParamsHandling: "merge" | 					queryParamsHandling: "merge" | ||||||
| 				}); | 				}); | ||||||
| 				return; | 				return; | ||||||
| @ -142,6 +144,7 @@ export class ItemsGridComponent | |||||||
| 			{ | 			{ | ||||||
| 				this.router.navigate(["studio", this.filters.studio.slug], { | 				this.router.navigate(["studio", this.filters.studio.slug], { | ||||||
| 					replaceUrl: true, | 					replaceUrl: true, | ||||||
|  | 					queryParams: {[category]: null}, | ||||||
| 					queryParamsHandling: "merge" | 					queryParamsHandling: "merge" | ||||||
| 				}); | 				}); | ||||||
| 				return; | 				return; | ||||||
| @ -152,7 +155,7 @@ export class ItemsGridComponent | |||||||
| 				if (this.router.url.startsWith("/studio")) | 				if (this.router.url.startsWith("/studio")) | ||||||
| 					params.studio = this.route.snapshot.params.slug; | 					params.studio = this.route.snapshot.params.slug; | ||||||
| 				if (this.router.url.startsWith("/genre") && category != "genres") | 				if (this.router.url.startsWith("/genre") && category != "genres") | ||||||
| 					params.genres = `ctn:${this.route.snapshot.params.slug}`; | 					params.genres = `${this.route.snapshot.params.slug}`; | ||||||
| 
 | 
 | ||||||
| 				this.router.navigate(["/browse"], { | 				this.router.navigate(["/browse"], { | ||||||
| 					queryParams: params, | 					queryParams: params, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user