Skip to content

Commit

Permalink
fixed the additional api calls happening on my expense page (#3070)
Browse files Browse the repository at this point in the history
  • Loading branch information
devendrafyle committed Jun 18, 2024
1 parent 5967e8f commit 9bd06af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/app/core/services/transaction.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { DateService } from './date.service';
import { map, switchMap, concatMap, reduce } from 'rxjs/operators';
import { map, switchMap, concatMap, reduce, tap } from 'rxjs/operators';
import { StorageService } from './storage.service';
import { from, Observable, range, forkJoin, of } from 'rxjs';
import { ApiV2Service } from './api-v2.service';
Expand Down Expand Up @@ -58,6 +58,8 @@ type PaymentMode = {
providedIn: 'root',
})
export class TransactionService {
private clearTaskCache = true;

constructor(
@Inject(PAGINATION_SIZE) private paginationSize: number,
private storageService: StorageService,
Expand All @@ -77,7 +79,9 @@ export class TransactionService {
private ldService: LaunchDarklyService
) {
expensesCacheBuster$.subscribe(() => {
this.userEventService.clearTaskCache();
if (this.clearTaskCache) {
this.userEventService.clearTaskCache();
}
});
}

Expand All @@ -90,8 +94,12 @@ export class TransactionService {
cacheBusterNotifier: expensesCacheBuster$,
isInstant: true,
})
clearCache(): Observable<null> {
return of(null);
clearCache(clearTaskCache: boolean = true): Observable<null> {
return of(null).pipe(
tap(() => {
this.clearTaskCache = clearTaskCache;
})
);
}

@CacheBuster({
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/my-expenses/my-expenses.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ export class MyExpensesPage implements OnInit {
}
const params = this.loadExpenses$.getValue();
params.pageNumber = this.currentPageNumber;
this.transactionService.clearCache().subscribe(() => {
this.transactionService.clearCache(false).subscribe(() => {
this.loadExpenses$.next(params);
if (event) {
setTimeout(() => {
Expand Down

0 comments on commit 9bd06af

Please sign in to comment.