2018-03-17 17:25:40 +01:00
|
|
|
import { Component, OnInit, OnDestroy } from "@angular/core";
|
|
|
|
import { Subscription, BehaviorSubject } from "rxjs";
|
|
|
|
|
2018-03-16 04:48:30 +01:00
|
|
|
import { AccountWrapper } from "../../models/account.models";
|
2018-03-17 17:25:40 +01:00
|
|
|
import { AccountsService, LocalAccount } from "../../services/accounts.service";
|
2018-03-16 01:43:53 +01:00
|
|
|
|
|
|
|
@Component({
|
2018-03-16 04:48:30 +01:00
|
|
|
selector: "app-left-side-bar",
|
|
|
|
templateUrl: "./left-side-bar.component.html",
|
|
|
|
styleUrls: ["./left-side-bar.component.css"]
|
2018-03-16 01:43:53 +01:00
|
|
|
})
|
2018-03-17 17:25:40 +01:00
|
|
|
export class LeftSideBarComponent implements OnInit, OnDestroy {
|
2018-03-16 03:43:41 +01:00
|
|
|
accounts: AccountWrapper[] = [];
|
2018-03-16 01:43:53 +01:00
|
|
|
|
2018-03-17 17:25:40 +01:00
|
|
|
private sub: Subscription;
|
2018-03-16 03:43:41 +01:00
|
|
|
|
2018-03-17 17:25:40 +01:00
|
|
|
constructor(
|
|
|
|
private readonly accountsService: AccountsService) { }
|
2018-03-16 03:43:41 +01:00
|
|
|
|
2018-03-17 17:25:40 +01:00
|
|
|
ngOnInit() {
|
|
|
|
this.accountsService.init.then(() => {
|
|
|
|
this.sub = this.accountsService.accountsSubject.subscribe((accounts: LocalAccount[]) => {
|
|
|
|
this.accounts.length = 0;
|
|
|
|
|
|
|
|
for (let acc of accounts) {
|
|
|
|
const acc1 = new AccountWrapper();
|
|
|
|
acc1.username = acc.mastodonAccount.username;
|
|
|
|
acc1.avatar = acc.mastodonAccount.avatar;
|
|
|
|
this.accounts.push(acc1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//const acc1 = new AccountWrapper();
|
|
|
|
//acc1.username = "@mastodon.social@Gargron";
|
|
|
|
//acc1.avatar = "https://files.mastodon.social/accounts/avatars/000/000/001/original/4df197532c6b768c.png";
|
|
|
|
//this.accounts.push(acc1);
|
|
|
|
|
|
|
|
//const acc2 = new AccountWrapper();
|
|
|
|
//acc2.username = "@mastodon.art@DearMsDearn";
|
|
|
|
//acc2.avatar = "https://curate.mastodon.art/gallery/accounts/avatars/000/015/092/original/3a112863f2dd22a27764179912dc8984.gif";
|
|
|
|
//this.accounts.push(acc2);
|
2018-03-16 03:43:41 +01:00
|
|
|
|
|
|
|
|
2018-03-17 17:25:40 +01:00
|
|
|
}
|
2018-03-16 03:43:41 +01:00
|
|
|
|
2018-03-17 17:25:40 +01:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
this.sub.unsubscribe();
|
2018-03-16 01:43:53 +01:00
|
|
|
}
|
|
|
|
|
2018-03-16 03:43:41 +01:00
|
|
|
toogleAccount(accountId: number): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
addNewAccount(): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
createNewToot(): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
2018-03-16 01:43:53 +01:00
|
|
|
}
|