import { Injectable } from '@angular/core';
// import { MatSnackBar, MatDialog } from '@angular/material';
import { Location } from '@angular/common';
import { Router } from '@angular/router';

import { Effect, Actions, ofType } from '@ngrx/effects';
import { map, tap } from 'rxjs/operators';

@Injectable()
export class Effects {
  constructor(
    private actions$: Actions,
    private router: Router,
    private location: Location,
    // private matSnackBar: MatSnackBar,
    // private matDialog: MatDialog,
  ) { }

  // @Effect({ dispatch: false })
  // userProfileGotoProfile$ = this.actions$.pipe(
  //   ofType(UserProfileStore.ActionType.GotoProfile),
  //   map((action: UserProfileStore.GotoProfile) => action.payload),
  //   tap((payload: { uid: string }) => {
  //     this.matDialog.closeAll();
  //     this.router.navigateByUrl(`/article/${payload.uid}`);
  //   }),
  // );

  // @Effect({ dispatch: false })
  // userProfileGotoProfileEdit$ = this.actions$.pipe(
  //   ofType(UserProfileStore.ActionType.GotoProfileEdit),
  //   tap(() => {
  //     this.router.navigateByUrl(`/user/edit`);
  //   }),
  // );

  // @Effect({ dispatch: false })
  // userProfileGotoSettings$ = this.actions$.pipe(
  //   ofType(UserProfileStore.ActionType.GotoSettings),
  //   tap(() => {
  //     this.router.navigateByUrl(`/user/settings`);
  //   }),
  // );

  // @Effect({ dispatch: false })
  // articleRouterGotoSave$ = this.actions$.pipe(
  //   ofType(ArticleRouterStore.ActionType.GotoSave),
  //   map((action: ArticleRouterStore.GotoSave) => action.payload),
  //   tap((payload: { aid: string }) => {
  //     this.matDialog.closeAll();
  //     this.router.navigateByUrl(`/article/write/${payload.aid}`);
  //   }),
  // );

}
