diff --git a/src/app/core/services/transaction.service.ts b/src/app/core/services/transaction.service.ts index 5f754410de..67a459ec20 100644 --- a/src/app/core/services/transaction.service.ts +++ b/src/app/core/services/transaction.service.ts @@ -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'; @@ -58,6 +58,8 @@ type PaymentMode = { providedIn: 'root', }) export class TransactionService { + private clearTaskCache = true; + constructor( @Inject(PAGINATION_SIZE) private paginationSize: number, private storageService: StorageService, @@ -77,7 +79,9 @@ export class TransactionService { private ldService: LaunchDarklyService ) { expensesCacheBuster$.subscribe(() => { - this.userEventService.clearTaskCache(); + if (this.clearTaskCache) { + this.userEventService.clearTaskCache(); + } }); } @@ -90,8 +94,12 @@ export class TransactionService { cacheBusterNotifier: expensesCacheBuster$, isInstant: true, }) - clearCache(): Observable { - return of(null); + clearCache(clearTaskCache: boolean = true): Observable { + return of(null).pipe( + tap(() => { + this.clearTaskCache = clearTaskCache; + }) + ); } @CacheBuster({ diff --git a/src/app/fyle/my-expenses/my-expenses.page.ts b/src/app/fyle/my-expenses/my-expenses.page.ts index 1271a5a40a..6475631e0d 100644 --- a/src/app/fyle/my-expenses/my-expenses.page.ts +++ b/src/app/fyle/my-expenses/my-expenses.page.ts @@ -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(() => {