Skip to content

Commit

Permalink
Fix bug that caused IMDB Search tab to not appear in mobile app due t…
Browse files Browse the repository at this point in the history
…o not getting the IMDBSearchEnabled status at the right time due to timing issue. Fixed by getting status directly in backend service
  • Loading branch information
Segi Hovav committed Dec 17, 2021
1 parent 38ee7e8 commit d485014
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
16 changes: 14 additions & 2 deletions src/app/core/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class DataService {
incompleteFilter = true;
isAdding = false;
isEditing = false;
isIMDBSearchEnabled = false;
isMobilePlatform = false;
platform: Platform;
recordLimit = 10;
Expand Down Expand Up @@ -175,6 +176,8 @@ export class DataService {
this.backendURL = await this.storage.get('BackEndURL');

if (this.backendURL != null && this.backendURL != "") {
this.getIMDBSearchEnabledSubscription();

this.getWatchListItemsSubscription(false);

this.getWatchListSubscription();
Expand Down Expand Up @@ -365,14 +368,23 @@ export class DataService {
}

return throwError(error || 'Node.js server error');
}
}

isBackendURLSet() {
return (this.backendURL != null && this.backendURL != '' ? true : false)
}

isIMDBSearchEnabled() {
getIMDBSearchEnabled() {
return this.processStep(`/IsIMDBSearchEnabled`,null);
}

getIMDBSearchEnabledSubscription() {
this.getIMDBSearchEnabled().subscribe((response) => {
this.isIMDBSearchEnabled=response;
},
error => {
this.handleError(error);
});
}

processStep(path: string, params: HttpParams): Observable<any> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/tabs/tabs.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ion-label>Watchlist Queue</ion-label>
</ion-tab-button>

<ion-tab-button tab="imdb-search" *ngIf="IMDBSearchEnabled != false">
<ion-tab-button tab="imdb-search" *ngIf="dataService.isIMDBSearchEnabled">
<!-- <ion-icon name="ellipse"></ion-icon> -->
<ion-label>IMDB Search</ion-label>
</ion-tab-button>
Expand Down
16 changes: 1 addition & 15 deletions src/app/tabs/tabs.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,5 @@ import { DataService } from '../core/data.service';
})

export class TabsPage {
IMDBSearchEnabled = false;

constructor(public dataService: DataService) {
if (this.dataService.isBackendURLSet())
this.getIMDBSearchEnabled()
}

getIMDBSearchEnabled() {
this.dataService.isIMDBSearchEnabled().subscribe((response) => {
this.IMDBSearchEnabled=response;
},
error => {
alert(`The error ${error.error.toString()} occurred calling isIMDBSearchEnabled() in TabsPage`)
});
}
constructor(public dataService: DataService) { }
}

0 comments on commit d485014

Please sign in to comment.