viewer: update title

pull/175/head
Varun Patil 2022-11-07 03:10:47 -08:00
parent cef50e1bb0
commit 33e863057e
1 changed files with 19 additions and 0 deletions

View File

@ -124,6 +124,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
@Emit("updateLoading") updateLoading(delta: number) {}
public isOpen = false;
private originalTitle = null;
private show = false;
private showControls = false;
@ -161,6 +162,22 @@ export default class Viewer extends Mixins(GlobalMixin) {
}
}
/** Update the document title */
private updateTitle(photo: IPhoto | undefined) {
const oc_defaults: any = globalThis.oc_defaults;
if (!this.originalTitle) {
this.originalTitle = document.title;
}
if (photo) {
document.title = `${photo.basename} - ${
globalThis.OCA.Theming?.name ?? oc_defaults.name
}`;
} else {
document.title = this.originalTitle;
this.originalTitle = null;
}
}
/** Get the currently open photo */
private getCurrentPhoto() {
if (!this.list.length || !this.photoswipe) {
@ -258,6 +275,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
this.showControls = false;
this.hideSidebar();
this.setRouteHash(undefined);
this.updateTitle(undefined);
});
this.photoswipe.on("destroy", () => {
document.body.classList.remove(klass);
@ -284,6 +302,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
// Update vue route for deep linking
this.photoswipe.on("slideActivate", (e) => {
this.setRouteHash(e.slide?.data?.photo);
this.updateTitle(e.slide?.data?.photo);
});
// Video support