...
 
Commits (2)
......@@ -52,6 +52,91 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('overlayModal', { static: true })
protected overlayModal: OverlayModalComponent;
get currentUser() {
if (!this.session.isLoggedIn()) {
return null;
}
return this.session.getLoggedInUser();
}
get homeRouterLink() {
return this.channelService.getRouterLink('home');
}
get feedRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('feed', params);
}
get videosRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('videos', params);
}
get imagesRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('images', params);
}
get articlesRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('articles', params);
}
get groupsRouterLink() {
return this.channelService.getRouterLink('groups');
}
get proSettingsLink() {
return ['/pro/settings'];
}
get proSettingsHref() {
return window.Minds.site_url + 'pro/settings';
}
get isProDomain() {
return this.site.isProDomain;
}
@HostBinding('style.backgroundImage') get backgroundImageCssValue() {
if (!this.channel) {
return 'none';
}
return `url(${this.channel.pro_settings.background_image})`;
}
@HostBinding('class') get cssColorSchemeOverride() {
if (!this.channel) {
return '';
}
return `m-theme--wrapper m-theme--wrapper__${this.channel.pro_settings
.scheme || 'light'}`;
}
constructor(
protected element: ElementRef,
protected session: Session,
......@@ -109,6 +194,10 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
});
}
@HostListener('window:resize') onResize() {
this.collapseNavItems = window.innerWidth <= 768;
}
setTitle() {
if (!this.channel) {
this.title.setTitle(this.username || 'Minds Pro');
......@@ -117,8 +206,8 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
const title = [
(this.channel.pro_settings.title as string) ||
this.channel.name ||
this.channel.username,
this.channel.name ||
this.channel.username,
];
switch (this.type) {
......@@ -166,14 +255,12 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
this.channel = await this.channelService.load(this.username);
this.bindCssVariables();
this.setTitle();
if (this.sessionStorage.get('pro::wire-modal::open')) {
this.wire();
}
} catch (e) {
this.error = e.getMessage();
}
this.shouldOpenWireModal();
this.detectChanges();
}
......@@ -184,6 +271,8 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
this.error = e.getMessage();
}
this.shouldOpenWireModal();
this.detectChanges();
}
......@@ -213,27 +302,6 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
this.channelService.wire();
}
@HostBinding('style.backgroundImage') get backgroundImageCssValue() {
if (!this.channel) {
return 'none';
}
return `url(${this.channel.pro_settings.background_image})`;
}
@HostBinding('class') get cssColorSchemeOverride() {
if (!this.channel) {
return '';
}
return `m-theme--wrapper m-theme--wrapper__${this.channel.pro_settings
.scheme || 'light'}`;
}
@HostListener('window:resize') onResize() {
this.collapseNavItems = window.innerWidth <= 768;
}
search(): Promise<boolean> {
return this.router.navigate(
this.channelService.getRouterLink('all', { query: this.query })
......@@ -251,71 +319,9 @@ export class ProChannelComponent implements OnInit, AfterViewInit, OnDestroy {
this.cd.detectChanges();
}
get currentUser() {
if (!this.session.isLoggedIn()) {
return null;
}
return this.session.getLoggedInUser();
}
get homeRouterLink() {
return this.channelService.getRouterLink('home');
}
get feedRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
private shouldOpenWireModal() {
if (this.sessionStorage.get('pro::wire-modal::open')) {
this.wire();
}
return this.channelService.getRouterLink('feed', params);
}
get videosRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('videos', params);
}
get imagesRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('images', params);
}
get articlesRouterLink() {
let params;
if (this.query) {
params = { query: this.query };
}
return this.channelService.getRouterLink('articles', params);
}
get groupsRouterLink() {
return this.channelService.getRouterLink('groups');
}
get proSettingsLink() {
return ['/pro/settings'];
}
get proSettingsHref() {
return window.Minds.site_url + 'pro/settings';
}
get isProDomain() {
return this.site.isProDomain;
}
}
......@@ -6,7 +6,7 @@ import { EntitiesService } from '../../../common/services/entities.service';
import normalizeUrn from '../../../helpers/normalize-urn';
import { OverlayModalService } from '../../../services/ux/overlay-modal';
import { Session } from '../../../services/session';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { WireCreatorComponent } from '../../wire/creator/creator.component';
import { SessionsStorageService } from '../../../services/session-storage.service';
import { SiteService } from '../../../services/site.service';
......@@ -29,6 +29,12 @@ export interface NavItems {
isActive: () => boolean;
}
type PaginationParams = { limit?: number, offset?: any };
type FeedsResponse = {
content: Array<any>;
offset: any;
};
@Injectable()
export class ProChannelService implements OnDestroy {
currentChannel: MindsUser;
......@@ -48,7 +54,8 @@ export class ProChannelService implements OnDestroy {
protected route: ActivatedRoute,
protected modalService: OverlayModalService,
protected sessionStorage: SessionsStorageService,
protected site: SiteService
protected router: Router,
protected site: SiteService,
) {
this.listen();
}
......@@ -128,21 +135,15 @@ export class ProChannelService implements OnDestroy {
return this.featuredContent;
}
async getContent({
limit,
offset,
}: { limit?: number; offset? } = {}): Promise<{
content: Array<any>;
offset: any;
}> {
async getContent(params: PaginationParams = {}): Promise<FeedsResponse> {
if (!this.currentChannel) {
throw new Error('No channel');
}
const endpoint = `api/v2/feeds/channel/${this.currentChannel.guid}/all/top`;
const qs = {
limit: limit || 24,
from_timestamp: offset || '',
limit: params.limit || 24,
from_timestamp: params.offset || '',
sync: 1,
exclude:
(this.currentChannel.pro_settings.featured_content || []).join(',') ||
......@@ -310,7 +311,18 @@ export class ProChannelService implements OnDestroy {
}
wire() {
// save into sessionStorage before doing the logged in check so the modal opens after logging in
this.sessionStorage.set('pro::wire-modal::open', '1');
if (!this.session.isLoggedIn()) {
this.router.navigate(['/login']);
return;
}
if (this.session.getLoggedInUser().guid == this.currentChannel.guid) {
return;
}
this.modalService
.create(WireCreatorComponent, this.currentChannel, {
onComplete: () => {
......