From 4e453bc5ac0d8c038e687c6edc4b8bd56af720da Mon Sep 17 00:00:00 2001 From: Devendra Singh Rana <132900359+devendrafyle@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:03:26 +0530 Subject: [PATCH] fix: fixed duplicate calls for reports (#3055) --- .../fyle/add-edit-expense/add-edit-expense.page.ts | 10 +++------- .../fyle/add-edit-mileage/add-edit-mileage.page.ts | 10 +++------- .../fyle/add-edit-per-diem/add-edit-per-diem.page.ts | 11 +++-------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/app/fyle/add-edit-expense/add-edit-expense.page.ts b/src/app/fyle/add-edit-expense/add-edit-expense.page.ts index 07d94c95ca..cdd6920d26 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense.page.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense.page.ts @@ -3176,13 +3176,9 @@ export class AddEditExpensePage implements OnInit { map((reports) => reports.filter((report) => !report.approvals.some((approval) => approval.state === 'APPROVAL_DONE')) ), - map((reports: Report[]) => reports.map((report) => ({ label: report.purpose, value: report }))) - ) as Observable< - { - label: string; - value: Report; - }[] - >; + map((reports: Report[]) => reports.map((report) => ({ label: report.purpose, value: report }))), + shareReplay(1) + ); this.recentlyUsedCategories$ = forkJoin({ filteredCategories: this.filteredCategories$.pipe(take(1)), diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index 1b6b1b1317..a72d086b74 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -1648,13 +1648,9 @@ export class AddEditMileagePage implements OnInit { map((reports) => reports.filter((report) => !report.approvals.some((approval) => approval.state === 'APPROVAL_DONE')) ), - map((reports: Report[]) => reports.map((report) => ({ label: report.purpose, value: report }))) - ) as Observable< - { - label: string; - value: Report; - }[] - >; + map((reports: Report[]) => reports.map((report) => ({ label: report.purpose, value: report }))), + shareReplay(1) + ); this.setupTxnFields(); diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts index a42a5559c3..1297b08fbf 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts @@ -104,7 +104,6 @@ import { ExtendedAccount } from 'src/app/core/models/extended-account.model'; import { OutboxQueue } from 'src/app/core/models/outbox-queue.model'; import { AllowedPerDiemRateOptions } from 'src/app/core/models/allowed-per-diem-rate-options.model'; import { PerDiemReports } from 'src/app/core/models/per-diem-reports.model'; -import { Report } from 'src/app/core/models/platform/v1/report.model'; import { TransactionState } from 'src/app/core/models/transaction-state.enum'; import { ToastType } from 'src/app/core/enums/toast-type.enum'; import { Expense } from 'src/app/core/models/expense.model'; @@ -1092,13 +1091,9 @@ export class AddEditPerDiemPage implements OnInit { reports .filter((report) => !report.approvals.some((approval) => approval.state === 'APPROVAL_DONE')) .map((report) => ({ label: report.purpose, value: report })) - ) - ) as Observable< - { - label: string; - value: Report; - }[] - >; + ), + shareReplay(1) + ); this.txnFields$ .pipe(