2019-04-07 22:47:29 +02:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2019-03-02 08:01:53 +01:00
|
|
|
import { faTimes } from "@fortawesome/free-solid-svg-icons";
|
|
|
|
|
2018-09-22 06:22:51 +02:00
|
|
|
import { NavigationService, LeftPanelType } from '../../services/navigation.service';
|
2018-09-11 07:54:23 +02:00
|
|
|
import { AccountWrapper } from '../../models/account.models';
|
2019-02-20 04:38:15 +01:00
|
|
|
import { OpenThreadEvent } from '../../services/tools.service';
|
2019-04-07 22:47:29 +02:00
|
|
|
import { Subscription } from 'rxjs';
|
2018-09-10 03:55:16 +02:00
|
|
|
|
|
|
|
@Component({
|
2018-09-22 06:22:51 +02:00
|
|
|
selector: 'app-floating-column',
|
|
|
|
templateUrl: './floating-column.component.html',
|
|
|
|
styleUrls: ['./floating-column.component.scss']
|
2018-09-10 03:55:16 +02:00
|
|
|
})
|
2019-04-07 22:47:29 +02:00
|
|
|
export class FloatingColumnComponent implements OnInit, OnDestroy {
|
|
|
|
|
2019-03-02 08:01:53 +01:00
|
|
|
faTimes = faTimes;
|
2018-11-08 05:31:47 +01:00
|
|
|
overlayActive: boolean;
|
2018-11-08 05:53:33 +01:00
|
|
|
overlayAccountToBrowse: string;
|
|
|
|
overlayHashtagToBrowse: string;
|
2019-02-20 04:38:15 +01:00
|
|
|
overlayThreadToBrowse: OpenThreadEvent;
|
2018-11-08 05:53:33 +01:00
|
|
|
|
2018-09-22 06:22:51 +02:00
|
|
|
userAccountUsed: AccountWrapper;
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2019-04-07 22:47:29 +02:00
|
|
|
openPanel: string = '';
|
|
|
|
|
|
|
|
private activatedPanelSub: Subscription;
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2018-09-22 06:22:51 +02:00
|
|
|
constructor(private readonly navigationService: NavigationService) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
2019-04-07 22:47:29 +02:00
|
|
|
this.activatedPanelSub = this.navigationService.activatedPanelSubject.subscribe((type: LeftPanelType) => {
|
2018-09-22 06:22:51 +02:00
|
|
|
switch (type) {
|
|
|
|
case LeftPanelType.Closed:
|
|
|
|
this.openPanel = '';
|
|
|
|
break;
|
|
|
|
case LeftPanelType.AddNewAccount:
|
2019-04-07 22:47:29 +02:00
|
|
|
if (this.openPanel === 'addNewAccount') {
|
|
|
|
this.closePanel();
|
|
|
|
} else {
|
|
|
|
this.openPanel = 'addNewAccount';
|
|
|
|
}
|
2018-09-22 06:22:51 +02:00
|
|
|
break;
|
|
|
|
case LeftPanelType.CreateNewStatus:
|
2019-04-07 22:47:29 +02:00
|
|
|
if (this.openPanel === 'createNewStatus') {
|
|
|
|
this.closePanel();
|
|
|
|
} else {
|
|
|
|
this.openPanel = 'createNewStatus';
|
|
|
|
}
|
2018-09-22 06:22:51 +02:00
|
|
|
break;
|
|
|
|
case LeftPanelType.ManageAccount:
|
2019-04-07 22:47:29 +02:00
|
|
|
let lastUserAccountId = '';
|
|
|
|
if (this.userAccountUsed && this.userAccountUsed.info) {
|
|
|
|
lastUserAccountId = this.userAccountUsed.info.id;
|
|
|
|
}
|
|
|
|
this.userAccountUsed = this.navigationService.getAccountToManage();
|
|
|
|
|
|
|
|
if (this.openPanel === 'manageAccount' && this.userAccountUsed.info.id === lastUserAccountId) {
|
|
|
|
this.closePanel();
|
|
|
|
} else {
|
|
|
|
this.openPanel = 'manageAccount';
|
|
|
|
}
|
2018-09-22 06:22:51 +02:00
|
|
|
break;
|
|
|
|
case LeftPanelType.Search:
|
2019-04-07 22:47:29 +02:00
|
|
|
if (this.openPanel === 'search') {
|
|
|
|
this.closePanel();
|
|
|
|
} else {
|
|
|
|
this.openPanel = 'search';
|
|
|
|
}
|
2018-09-22 06:22:51 +02:00
|
|
|
break;
|
|
|
|
case LeftPanelType.Settings:
|
2019-04-07 22:47:29 +02:00
|
|
|
if (this.openPanel === 'settings') {
|
|
|
|
this.closePanel();
|
|
|
|
} else {
|
|
|
|
this.openPanel = 'settings';
|
|
|
|
}
|
2018-09-22 06:22:51 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this.openPanel = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-04-07 22:47:29 +02:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
if(this.activatedPanelSub) {
|
|
|
|
this.activatedPanelSub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-22 06:22:51 +02:00
|
|
|
closePanel(): boolean {
|
|
|
|
this.navigationService.closePanel();
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2018-11-08 05:53:33 +01:00
|
|
|
browseAccount(account: string): void {
|
|
|
|
this.overlayAccountToBrowse = account;
|
|
|
|
this.overlayHashtagToBrowse = null;
|
2019-02-20 04:38:15 +01:00
|
|
|
this.overlayThreadToBrowse = null;
|
2019-04-07 22:47:29 +02:00
|
|
|
this.overlayActive = true;
|
2018-11-08 05:53:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
browseHashtag(hashtag: string): void {
|
|
|
|
this.overlayAccountToBrowse = null;
|
|
|
|
this.overlayHashtagToBrowse = hashtag;
|
2019-02-20 04:38:15 +01:00
|
|
|
this.overlayThreadToBrowse = null;
|
2019-04-07 22:47:29 +02:00
|
|
|
this.overlayActive = true;
|
2018-11-08 05:53:33 +01:00
|
|
|
}
|
|
|
|
|
2019-02-20 04:38:15 +01:00
|
|
|
browseThread(openThreadEvent: OpenThreadEvent): void {
|
|
|
|
this.overlayAccountToBrowse = null;
|
|
|
|
this.overlayHashtagToBrowse = null;
|
|
|
|
this.overlayThreadToBrowse = openThreadEvent;
|
2019-04-07 22:47:29 +02:00
|
|
|
this.overlayActive = true;
|
2018-11-08 05:53:33 +01:00
|
|
|
}
|
|
|
|
|
2018-11-08 05:31:47 +01:00
|
|
|
closeOverlay(): boolean {
|
|
|
|
this.overlayActive = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-10 03:55:16 +02:00
|
|
|
}
|