|
1 |
| -import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; |
| 1 | +import { inject, Component, ChangeDetectionStrategy } from '@angular/core'; |
| 2 | +import { Album, Authentication, Photo } from '@devmx/shared-api-interfaces'; |
| 3 | +import { AlbumFacade, PhotoFacade } from '@devmx/album-data-access'; |
| 4 | +import { AuthenticationFacade } from '@devmx/account-data-access'; |
2 | 5 | import { ActivatedRoute, RouterModule } from '@angular/router';
|
3 |
| -import { Album } from '@devmx/shared-api-interfaces'; |
| 6 | +import { MatButtonModule } from '@angular/material/button'; |
4 | 7 | import { AsyncPipe } from '@angular/common';
|
5 |
| -import { filter, map } from 'rxjs'; |
| 8 | +import { filter, map, take } from 'rxjs'; |
| 9 | +import { |
| 10 | + PhotoComponent, |
| 11 | + PhotoViewerService, |
| 12 | + providePhotoViewer, |
| 13 | +} from '@devmx/album-ui-shared'; |
6 | 14 |
|
7 | 15 | @Component({
|
8 | 16 | selector: 'devmx-album',
|
9 | 17 | templateUrl: './album.container.html',
|
10 | 18 | styleUrl: './album.container.scss',
|
11 | 19 | changeDetection: ChangeDetectionStrategy.OnPush,
|
12 |
| - imports: [RouterModule, AsyncPipe], |
| 20 | + imports: [RouterModule, MatButtonModule, PhotoComponent, AsyncPipe], |
| 21 | + providers: [providePhotoViewer()], |
13 | 22 | })
|
14 | 23 | export class AlbumContainer {
|
15 | 24 | route = inject(ActivatedRoute);
|
16 | 25 |
|
| 26 | + authFacade = inject(AuthenticationFacade); |
| 27 | + albumFacade = inject(AlbumFacade); |
| 28 | + photoFacade = inject(PhotoFacade); |
| 29 | + |
| 30 | + photoViewer = inject(PhotoViewerService); |
| 31 | + |
17 | 32 | album$ = this.route.data.pipe(
|
18 | 33 | filter((data) => 'album' in data),
|
19 | 34 | map((data) => data['album'] as Album)
|
20 | 35 | );
|
| 36 | + |
| 37 | + open(photo: Photo, auth: Authentication) { |
| 38 | + this.photoViewer |
| 39 | + .open({ photo, auth }) |
| 40 | + .closed.pipe(take(1)) |
| 41 | + .subscribe(this.updateTags); |
| 42 | + } |
| 43 | + |
| 44 | + updateTags = (photo?: Photo) => { |
| 45 | + if (photo) this.photoFacade.updateTags(photo); |
| 46 | + }; |
21 | 47 | }
|
0 commit comments