Skip to content

Commit

Permalink
Merge pull request #176 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Fixed presentation share data when required fields are not in storage
  • Loading branch information
stzouvaras authored Oct 2, 2024
2 parents 66c9f72 + 5e75895 commit 7e77d42
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ open class BaseRequestViewModel<Router: RouterHost>: BaseViewModel<Router, Reque
title: title,
relyingParty: relyingParty,
isTrusted: isTrusted,
allowShare: !items.isEmpty,
allowShare: canShare(with: items),
initialized: true
)
.copy(error: nil)
Expand Down Expand Up @@ -238,7 +238,20 @@ open class BaseRequestViewModel<Router: RouterHost>: BaseViewModel<Router, Reque
.filter { !$0 }
.isEmpty

let hasVerificationItems = !items.compactMap { $0.isDataVerification }.isEmpty
setState {
$0.copy(
itemsAreAllSelected: allSelected,
items: items,
allowShare: canShare(with: items)
)
}
}

private func canShare(with items: [RequestDataUIModel]) -> Bool {

let hasVerificationItems = !items.compactMap {
$0.isDataVerification?.items.first(where: { $0.isSelected })
}.isEmpty

let onlyDataRowItems: [RequestDataUIModel] = items
.compactMap {
Expand All @@ -257,13 +270,7 @@ open class BaseRequestViewModel<Router: RouterHost>: BaseViewModel<Router, Reque
.filter { $0 }
.isEmpty

setState {
$0.copy(
itemsAreAllSelected: allSelected,
items: items,
allowShare: canShare || hasVerificationItems
)
}
return canShare || hasVerificationItems
}

private func onErrorAction() {
Expand Down

0 comments on commit 7e77d42

Please sign in to comment.