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 * as Hls from "hls.js";
|
||||
import { ShowService } from "../../services/api.service";
|
||||
import { StartupService } from "../../services/startup.service";
|
||||
import {
|
||||
getWhatIsSupported,
|
||||
method,
|
||||
@ -162,7 +163,8 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
private router: Router,
|
||||
private location: Location,
|
||||
private injector: Injector,
|
||||
private shows: ShowService)
|
||||
private shows: ShowService,
|
||||
private startup: StartupService)
|
||||
{ }
|
||||
|
||||
ngOnInit()
|
||||
@ -359,8 +361,14 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
back()
|
||||
{
|
||||
// TODO add the show page in the backstack if the user used a direct link to go to the watch page.
|
||||
this.location.back();
|
||||
if (this.startup.loadedFromWatch)
|
||||
{
|
||||
this.router.navigate(["show", this.startup.show], {replaceUrl: true})
|
||||
this.startup.loadedFromWatch = false;
|
||||
this.startup.show = null;
|
||||
}
|
||||
else
|
||||
this.location.back();
|
||||
}
|
||||
|
||||
next()
|
||||
|
@ -5,14 +5,17 @@ import { Injectable } from "@angular/core";
|
||||
})
|
||||
export class StartupService
|
||||
{
|
||||
loadedFromWatch: boolean = false;
|
||||
show: string = null;
|
||||
|
||||
constructor() {}
|
||||
|
||||
load(): Promise<any>
|
||||
{
|
||||
if (window.location.pathname.startsWith("/watch/"))
|
||||
{
|
||||
const show = window.location.pathname.match(/^\/watch\/(?<show>.*)(-s\d+e\d+)+?$/).groups["show"];
|
||||
history.pushState({}, null, `/show/${show}`)
|
||||
this.loadedFromWatch = true;
|
||||
this.show = window.location.pathname.match(/^\/watch\/(?<show>.*)(-s\d+e\d+)+?$/).groups["show"];
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user