import {Component, isDevMode} from '@angular/core';
import {Store} from "@ngrx/store";
import {MastodonApiActions} from "./shared/state/store/actions";
import {PersistentStore} from "./shared/state/persistent/persistent-store.service";

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
export class AppComponent {
    title = 'mastolists';

    navigationItems = [
        {title: 'Authorize', link: '/auth'},
        {title: 'Stats', link: '/sync'},
        {title: 'List view', link: '/list'},
        {title: 'Matrix View', link: '/matrix'},
        {title: 'Table View', link: '/table'},
    ];

    constructor(private store: Store, private persistentStore: PersistentStore) {
        if (this.persistentStore.isAuthorized() && !isDevMode()) {
            this.store.dispatch(MastodonApiActions.loadLists());
            this.store.dispatch(MastodonApiActions.loadFollowings());
        }
    }
}
