Skip to content

Commit

Permalink
Merge pull request #290 from lardbit/fix-newly-updated-record-fetching
Browse files Browse the repository at this point in the history
merge newly-updated-records only when filters were applied (reduced set)
  • Loading branch information
lardbit authored Jun 19, 2024
2 parents 6e1d0fb + c4f4ad3 commit 330ff26
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/frontend/src/app/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,12 @@ export class ApiService {
const httpParams = new HttpParams({fromObject: params});
return this.http.get(this.API_URL_WATCH_TV_SEASON, {params: httpParams, headers: this._requestHeaders()}).pipe(
map((records: any) => {
this._mergeMediaRecords(this.watchTVSeasons, records);
// if filter params are present we should merge the results
if (httpParams.keys().length > 0) {
this._mergeMediaRecords(this.watchTVSeasons, records);
} else {
this.watchTVSeasons = records;
}
return this.watchTVSeasons;
}),
);
Expand All @@ -467,7 +472,12 @@ export class ApiService {
const httpParams = new HttpParams({fromObject: params});
return this.http.get(this.API_URL_WATCH_TV_SEASON_REQUEST, {params: httpParams, headers: this._requestHeaders()}).pipe(
map((records: any) => {
this._mergeMediaRecords(this.watchTVSeasonRequests, records);
// if filter params are present we should merge the results
if (httpParams.keys().length > 0) {
this._mergeMediaRecords(this.watchTVSeasonRequests, records);
} else {
this.watchTVSeasonRequests = records;
}
return this.watchTVSeasonRequests;
}),
);
Expand All @@ -479,7 +489,12 @@ export class ApiService {

return this.http.get(this.API_URL_WATCH_MOVIE, {params: httpParams, headers: this._requestHeaders()}).pipe(
map((records: any[]) => {
this._mergeMediaRecords(this.watchMovies, records);
// if filter params are present we should merge the results
if (httpParams.keys().length > 0) {
this._mergeMediaRecords(this.watchMovies, records);
} else {
this.watchMovies = records;
}
return this.watchMovies;
}),
);
Expand All @@ -489,7 +504,12 @@ export class ApiService {
const httpParams = new HttpParams({fromObject: params});
return this.http.get(this.API_URL_WATCH_TV_EPISODE, {headers: this._requestHeaders(), params: httpParams}).pipe(
map((records: any) => {
this._mergeMediaRecords(this.watchTVEpisodes, records);
// if filter params are present we should merge the results
if (httpParams.keys().length > 0) {
this._mergeMediaRecords(this.watchTVEpisodes, records);
} else {
this.watchTVEpisodes = records;
}
return this.watchTVEpisodes;
}),
);
Expand Down

0 comments on commit 330ff26

Please sign in to comment.