mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Fixing player's back navigation when using direct link to the watch page
This commit is contained in:
parent
e6c5522329
commit
8e491123d6
@ -16,6 +16,7 @@ import { ActivatedRoute, Event, NavigationCancel, NavigationEnd, NavigationStart
|
|||||||
import { OidcSecurityService } from "angular-auth-oidc-client";
|
import { OidcSecurityService } from "angular-auth-oidc-client";
|
||||||
import * as Hls from "hls.js";
|
import * as Hls from "hls.js";
|
||||||
import { ShowService } from "../../services/api.service";
|
import { ShowService } from "../../services/api.service";
|
||||||
|
import { StartupService } from "../../services/startup.service";
|
||||||
import {
|
import {
|
||||||
getWhatIsSupported,
|
getWhatIsSupported,
|
||||||
method,
|
method,
|
||||||
@ -162,7 +163,8 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private injector: Injector,
|
private injector: Injector,
|
||||||
private shows: ShowService)
|
private shows: ShowService,
|
||||||
|
private startup: StartupService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
ngOnInit()
|
ngOnInit()
|
||||||
@ -359,8 +361,14 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
|
|||||||
|
|
||||||
back()
|
back()
|
||||||
{
|
{
|
||||||
// TODO add the show page in the backstack if the user used a direct link to go to the watch page.
|
if (this.startup.loadedFromWatch)
|
||||||
this.location.back();
|
{
|
||||||
|
this.router.navigate(["show", this.startup.show], {replaceUrl: true})
|
||||||
|
this.startup.loadedFromWatch = false;
|
||||||
|
this.startup.show = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.location.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
@ -5,14 +5,17 @@ import { Injectable } from "@angular/core";
|
|||||||
})
|
})
|
||||||
export class StartupService
|
export class StartupService
|
||||||
{
|
{
|
||||||
|
loadedFromWatch: boolean = false;
|
||||||
|
show: string = null;
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
load(): Promise<any>
|
load(): Promise<any>
|
||||||
{
|
{
|
||||||
if (window.location.pathname.startsWith("/watch/"))
|
if (window.location.pathname.startsWith("/watch/"))
|
||||||
{
|
{
|
||||||
const show = window.location.pathname.match(/^\/watch\/(?<show>.*)(-s\d+e\d+)+?$/).groups["show"];
|
this.loadedFromWatch = true;
|
||||||
history.pushState({}, null, `/show/${show}`)
|
this.show = window.location.pathname.match(/^\/watch\/(?<show>.*)(-s\d+e\d+)+?$/).groups["show"];
|
||||||
}
|
}
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user