various fixes to the entryRoute...

This commit is contained in:
X4Lo committed 2024-05-10 09:50:40 +01:00
1 parent 98f77b385c
commit 7fc1bdd875
3 files changed
+77 -17

No files matched your search

+12 -8
View File
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, map, of } from 'rxjs';
import { Observable, from, map, of, switchMap, toArray } from 'rxjs';
import { Entry } from '../../shared/models/entry.model';
import { EntryId } from '../../shared/models/entryId.model';
import { EntryRating } from '../../shared/models/entryRating.model';
@@ -75,14 +75,18 @@ export class TmdbService {
getByKeyword(keyword: string, type: string, page: number) {
var endPoint = `${this.tmdb_apiUrl}/search/${type}?query=${keyword}&page=${page}&api_key=${this.tmdb_apiKey}&language=en-US`;
// return this.getEntriesUsingEndPoint(endPoint);
return this.fetchdataNoCach(endPoint).pipe(
map((response) => {
return response.results.map((movie: any) =>
this.adaptMovieToEntry(movie)
);
})
switchMap((response) => from(response.results.map((movie: any) => this.adaptMovieToEntry(movie)))
.pipe(
toArray(),
map(entries => ({
entries: entries,
total_pages: response.total_pages,
total_results: response.total_results
}))
)
)
);
}