2018-09-10 03:55:16 +02:00
|
|
|
import { Component, OnInit, Input } from '@angular/core';
|
2018-09-11 06:35:19 +02:00
|
|
|
import { StreamElement, StreamTypeEnum, AddStream } from '../../../states/streams.state';
|
2018-09-10 04:33:41 +02:00
|
|
|
import { Store } from '@ngxs/store';
|
2018-09-11 07:54:23 +02:00
|
|
|
import { AccountsStateModel, AccountInfo } from '../../../states/accounts.state';
|
|
|
|
import { AccountWrapper } from '../../../models/account.models';
|
2018-09-10 03:55:16 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-01-28 06:46:37 +01:00
|
|
|
selector: 'app-manage-account',
|
|
|
|
templateUrl: './manage-account.component.html',
|
|
|
|
styleUrls: ['./manage-account.component.scss']
|
2018-09-10 03:55:16 +02:00
|
|
|
})
|
2018-09-22 06:22:51 +02:00
|
|
|
export class ManageAccountComponent implements OnInit {
|
2019-01-28 06:46:37 +01:00
|
|
|
@Input() account: AccountWrapper;
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2019-01-28 06:46:37 +01:00
|
|
|
availableStreams: StreamElement[] = [];
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2019-01-28 06:46:37 +01:00
|
|
|
constructor(private readonly store: Store) { }
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2019-01-28 06:46:37 +01:00
|
|
|
ngOnInit() {
|
|
|
|
const instance = this.account.info.instance;
|
|
|
|
this.availableStreams.length = 0;
|
|
|
|
this.availableStreams.push(new StreamElement(StreamTypeEnum.global, 'Federated Timeline', this.account.info.id, null, null, `federate@${instance}`));
|
|
|
|
this.availableStreams.push(new StreamElement(StreamTypeEnum.local, 'Local Timeline', this.account.info.id, null, null, `local@${instance}`));
|
|
|
|
this.availableStreams.push(new StreamElement(StreamTypeEnum.personnal, 'Home', this.account.info.id, null, null, `home@${instance}`));
|
|
|
|
}
|
2018-09-10 03:55:16 +02:00
|
|
|
|
2019-01-28 06:46:37 +01:00
|
|
|
addStream(stream: StreamElement): boolean {
|
|
|
|
if (stream) {
|
|
|
|
this.store.dispatch([new AddStream(stream)]);
|
|
|
|
}
|
|
|
|
return false;
|
2018-09-10 04:33:41 +02:00
|
|
|
}
|
2018-09-10 03:55:16 +02:00
|
|
|
}
|