diff --git a/frontend/src/app/shared/components/cards/main-card/main-card.component.html b/frontend/src/app/shared/components/cards/main-card/main-card.component.html index 760dbb1..399aa86 100644 --- a/frontend/src/app/shared/components/cards/main-card/main-card.component.html +++ b/frontend/src/app/shared/components/cards/main-card/main-card.component.html @@ -26,7 +26,6 @@
- diff --git a/frontend/src/app/shared/components/cards/main-card/main-card.component.ts b/frontend/src/app/shared/components/cards/main-card/main-card.component.ts index 8ce1534..2cd40be 100644 --- a/frontend/src/app/shared/components/cards/main-card/main-card.component.ts +++ b/frontend/src/app/shared/components/cards/main-card/main-card.component.ts @@ -1,7 +1,13 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { UserCollectionsModalComponent } from '../../modals/list-selection-modal/user-collections-modal.component'; import { MatDialog } from '@angular/material/dialog'; -import { trigger, transition, style, animate } from '@angular/animations'; +import { + trigger, + transition, + style, + animate, + state, +} from '@angular/animations'; import { Entry } from '../../../models/entry.model'; import { LibraryService } from '../../../../core/services/library.service'; import { Router } from '@angular/router'; @@ -13,18 +19,23 @@ import { Router } from '@angular/router'; animations: [ trigger('fadeInOut', [ transition(':enter', [ - // :enter is alias for 'void => *' - style({ opacity: 0 }), - animate('0.5s ease-out', style({ opacity: 1 })), + style({ opacity: 0, transform: 'translateY(-50px)' }), + animate( + '300ms ease-out', + style({ opacity: 1, transform: 'translateY(0)' }) + ), ]), transition(':leave', [ - // :leave is alias for '* => void' - animate('0.5s ease-in', style({ opacity: 0 })), + animate( + '300ms ease-in', + style({ opacity: 0, transform: 'translateY(-50px)' }) + ), ]), ]), ], }) export class MainCardComponent implements OnInit { + @Output() removedEvent = new EventEmitter(); @Input() entry!: Entry; constructor( @@ -55,14 +66,13 @@ export class MainCardComponent implements OnInit { addEntry(tmdb_id: string, is_tvserie: boolean) { console.log('Adding Entry To Library.'); - this.libraryService.addEntry(tmdb_id, is_tvserie).subscribe({ + let obs = this.libraryService.addEntry(tmdb_id, is_tvserie).subscribe({ next: (entry) => { if (entry != null) { console.log(`Entry added to library`, entry); entry.isInLibrary = true; this.entry = entry; - // todo emit event to > list > library to refrech - this.libraryService.getAllEntries(true); + obs.unsubscribe(); } }, error: (error) => { @@ -76,10 +86,11 @@ export class MainCardComponent implements OnInit { this.libraryService.deleteEntry(id).subscribe({ next: (response) => { console.log('Entry successfully deleted.', response); + // ? emit to dynamic entry list this.entry.id = 0; this.entry.isInLibrary = false; - // todo emit event to > list > library to refrech - this.libraryService.getAllEntries(true); + this.removedEvent.emit(this.entry.id); + // todo entry removed notification }, error: (error) => { console.error('Error deleting entry:', error); @@ -114,7 +125,11 @@ export class MainCardComponent implements OnInit { } isCertainRoute(): boolean { - return this.router.isActive('/search', true) || this.router.isActive('/popular', true) || this.router.isActive('/trending', true); + return ( + this.router.isActive('/search', true) || + this.router.isActive('/popular', true) || + this.router.isActive('/trending', true) + ); } get postPath() {