Commit 0889ccd9 authored by Juan Manuel Solaro's avatar Juan Manuel Solaro

(feat) set window title for pro settings and pro channel

1 merge request!459WIP: (feat): Minds Pro (development branch)
Pipeline #74982543 failed with stages
in 34 minutes and 9 seconds
......@@ -12,7 +12,7 @@ import { Session } from "../../../services/session";
import { Subscription } from "rxjs";
import { MindsUser } from "../../../interfaces/entities";
import { Client } from "../../../services/api/client";
import { Title } from "@angular/platform-browser";
import { MindsTitle } from '../../../services/ux/title';
import { ProChannelService } from './channel.service';
@Component({
......@@ -48,7 +48,7 @@ export class ProChannelComponent implements OnInit, OnDestroy {
protected session: Session,
protected channelService: ProChannelService,
protected client: Client,
protected title: Title,
protected title: MindsTitle,
protected router: Router,
protected route: ActivatedRoute,
protected cd: ChangeDetectorRef,
......@@ -69,6 +69,7 @@ export class ProChannelComponent implements OnInit, OnDestroy {
}
this.currentURL = navigationEvent.urlAfterRedirects;
this.setTitle();
}
} catch (e) {
console.error('Minds: router hook(SearchBar)', e);
......@@ -86,6 +87,22 @@ export class ProChannelComponent implements OnInit, OnDestroy {
});
}
setTitle() {
const urlFragments = this.router.url.split('/');
const fragmentIndex = urlFragments.findIndex(v => v === "juanmsolaro") + 1;
let title = this.channel.pro_settings.title as string || this.channel.name;
if (this.channel.pro_settings.headline) {
title += ` - ${this.channel.pro_settings.headline}`;
}
if (urlFragments[fragmentIndex]) {
title += ` - ${urlFragments[fragmentIndex]}`;
}
this.title.setTitle(title);
}
ngOnDestroy() {
this.params$.unsubscribe();
this.routerSubscription.unsubscribe();
......@@ -102,15 +119,8 @@ export class ProChannelComponent implements OnInit, OnDestroy {
try {
this.channel = await this.channelService.load(this.username);
let title = this.channel.pro_settings.title as string || this.channel.name;
this.bindCssVariables();
if (this.channel.pro_settings.headline) {
title += ` - ${this.channel.pro_settings.headline}`;
}
this.title.setTitle(title);
this.setTitle();
} catch (e) {
this.error = e.getMessage();
}
......
......@@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@
import { ProService } from '../pro.service';
import { Session } from '../../../services/session';
import { Router } from '@angular/router';
import { MindsTitle } from '../../../services/ux/title';
@Component({
selector: 'm-pro--settings',
......@@ -23,6 +24,7 @@ export class ProSettingsComponent implements OnInit {
protected session: Session,
protected router: Router,
protected cd: ChangeDetectorRef,
protected title: MindsTitle
) {
}
......@@ -43,6 +45,8 @@ export class ProSettingsComponent implements OnInit {
this.settings = settings;
this.title.setTitle('Pro Settings');
this.inProgress = false;
this.detectChanges();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment