changed animation + fix entry add duping error

This commit is contained in:
X4Lo committed 2024-04-28 22:03:51 +01:00
1 parent 42726c5881
commit 4c665f005a
2 files changed
+28 -14

No files matched your search

@@ -26,7 +26,6 @@
<div class="info" *ngIf="entry.isInLibrary"> <div class="info" *ngIf="entry.isInLibrary">
<i class='bx bx-list-plus' (click)="showAddToListModal()"></i> <i class='bx bx-list-plus' (click)="showAddToListModal()"></i>
</div> </div>
</div> </div>
<!-- card body : title, --> <!-- card body : title, -->
@@ -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 { UserCollectionsModalComponent } from '../../modals/list-selection-modal/user-collections-modal.component';
import { MatDialog } from '@angular/material/dialog'; 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 { Entry } from '../../../models/entry.model';
import { LibraryService } from '../../../../core/services/library.service'; import { LibraryService } from '../../../../core/services/library.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@@ -13,18 +19,23 @@ import { Router } from '@angular/router';
animations: [ animations: [
trigger('fadeInOut', [ trigger('fadeInOut', [
transition(':enter', [ transition(':enter', [
// :enter is alias for 'void => *' style({ opacity: 0, transform: 'translateY(-50px)' }),
style({ opacity: 0 }), animate(
animate('0.5s ease-out', style({ opacity: 1 })), '300ms ease-out',
style({ opacity: 1, transform: 'translateY(0)' })
),
]), ]),
transition(':leave', [ transition(':leave', [
// :leave is alias for '* => void' animate(
animate('0.5s ease-in', style({ opacity: 0 })), '300ms ease-in',
style({ opacity: 0, transform: 'translateY(-50px)' })
),
]), ]),
]), ]),
], ],
}) })
export class MainCardComponent implements OnInit { export class MainCardComponent implements OnInit {
@Output() removedEvent = new EventEmitter();
@Input() entry!: Entry; @Input() entry!: Entry;
constructor( constructor(
@@ -55,14 +66,13 @@ export class MainCardComponent implements OnInit {
addEntry(tmdb_id: string, is_tvserie: boolean) { addEntry(tmdb_id: string, is_tvserie: boolean) {
console.log('Adding Entry To Library.'); 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) => { next: (entry) => {
if (entry != null) { if (entry != null) {
console.log(`Entry added to library`, entry); console.log(`Entry added to library`, entry);
entry.isInLibrary = true; entry.isInLibrary = true;
this.entry = entry; this.entry = entry;
// todo emit event to > list > library to refrech obs.unsubscribe();
this.libraryService.getAllEntries(true);
} }
}, },
error: (error) => { error: (error) => {
@@ -76,10 +86,11 @@ export class MainCardComponent implements OnInit {
this.libraryService.deleteEntry(id).subscribe({ this.libraryService.deleteEntry(id).subscribe({
next: (response) => { next: (response) => {
console.log('Entry successfully deleted.', response); console.log('Entry successfully deleted.', response);
// ? emit to dynamic entry list
this.entry.id = 0; this.entry.id = 0;
this.entry.isInLibrary = false; this.entry.isInLibrary = false;
// todo emit event to > list > library to refrech this.removedEvent.emit(this.entry.id);
this.libraryService.getAllEntries(true); // todo entry removed notification
}, },
error: (error) => { error: (error) => {
console.error('Error deleting entry:', error); console.error('Error deleting entry:', error);
@@ -114,7 +125,11 @@ export class MainCardComponent implements OnInit {
} }
isCertainRoute(): boolean { 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() { get postPath() {