This repository has been archived on 2024-11-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mastodon-apps/projects/mastolists/src/app/followings/followings/followings.component.ts
2022-12-22 16:38:25 +01:00

34 lines
1.4 KiB
TypeScript

import {Component} from '@angular/core';
import {PersistentStore} from "../../shared/state/persistent/persistent-store.service";
import {Account, List, MastodonApiListsService} from 'projects/mastodon-api/src/public-api';
import {NbToastrService} from "@nebular/theme";
import {ListService} from "../../shared/services/list.service";
import {Observable} from "rxjs";
import {select, Store} from "@ngrx/store";
import {selectFilteredFollowingsWithLists, selectFollowings, selectFollowingsWithLists, selectLists} from "../../shared/state/store/selectors";
import {FiltersActions, ListActions, MastodonApiActions} from "../../shared/state/store/actions";
@Component({
selector: 'app-followings',
templateUrl: './followings.component.html',
styleUrls: ['./followings.component.scss']
})
export class FollowingsComponent {
followings$: Observable<ReadonlyArray<Account>>;
lists$: Observable<ReadonlyArray<List>>;
constructor(private store: Store) {
this.followings$ = this.store.pipe(select(selectFilteredFollowingsWithLists));
this.lists$ = this.store.pipe(select(selectLists));
}
addAccountToSelectedList(accountId: string, select: HTMLSelectElement) {
this.store.dispatch(ListActions.addAccountToList({accountId, listId: select.value}));
}
removeAccountFromList(accountId: string, listId: string) {
this.store.dispatch(ListActions.removeAccountFromList({accountId, listId}));
}
}