From 835de3f7cc603d32f5b8c5e1c29ee60153b08fb1 Mon Sep 17 00:00:00 2001 From: Mumthezir Date: Mon, 22 Apr 2024 12:56:42 +0530 Subject: [PATCH] Fix #229: Consent status is shown as disabled in some scenario --- .../BBConsentOrganisationViewController.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift b/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift index aa77e14..81c900f 100644 --- a/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift +++ b/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift @@ -141,6 +141,8 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController { func CheckAndCreateRecordForContractType() { let dataAgreementIDs = dataAgreementsObj?.dataAgreements.filter({ $0.lawfulBasis != "consent" && $0.lawfulBasis != "legitimate_interest" }).map({ $0.id }) ?? [] let idsWithAttributeRecords = consentRecordsObj?.consentRecords.map({ $0.dataAgreementID }) ?? [] + let recordIds = consentRecordsObj?.consentRecords.map({ $0.id }) ?? [] + for item in dataAgreementIDs { // If item doesnt have record already if !idsWithAttributeRecords.contains(item) { @@ -151,6 +153,15 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController { self.orgTableView.reloadData() } } + } else { + // Update record api call + let indexOfItem = idsWithAttributeRecords.firstIndex(of: item) ?? 0 + callUpdatePurposeApi(dataAgreementRecordId: recordIds[indexOfItem], dataAgreementId: item, status: true) { success in + if success { + self.consentRecordsObj?.consentRecords[indexOfItem].optIn = true + self.orgTableView.reloadData() + } + } } } }