Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MBL-1681] Fix confirm details bonus #2146

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Kickstarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
39B8507C2C3EC52D0045CBA5 /* ButtonStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39B8507B2C3EC52D0045CBA5 /* ButtonStyles.swift */; };
39C6169E2BC83DB000732410 /* PostCampaignPledgeRewardsSummaryViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39C6169D2BC83DB000732410 /* PostCampaignPledgeRewardsSummaryViewModelTests.swift */; };
39E436F52C7FA5F3009707BE /* SharedPledgeViewStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39E436F42C7FA5F3009707BE /* SharedPledgeViewStyles.swift */; };
39E436F72C88D7D2009707BE /* NoShippingConfirmDetailsViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39E436F62C88D7D2009707BE /* NoShippingConfirmDetailsViewModelTests.swift */; };
4705D8982742E20900A13BBE /* ProjectHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4705D8972742E20900A13BBE /* ProjectHeaderCell.swift */; };
471235F7274450AC0035527F /* ProjectPamphletMainCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 471235F6274450AC0035527F /* ProjectPamphletMainCell.xib */; };
471235F9274457460035527F /* ProjectPamphletSubpageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 471235F8274457460035527F /* ProjectPamphletSubpageCell.xib */; };
Expand Down Expand Up @@ -2005,6 +2006,7 @@
39B8507B2C3EC52D0045CBA5 /* ButtonStyles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonStyles.swift; sourceTree = "<group>"; };
39C6169D2BC83DB000732410 /* PostCampaignPledgeRewardsSummaryViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostCampaignPledgeRewardsSummaryViewModelTests.swift; sourceTree = "<group>"; };
39E436F42C7FA5F3009707BE /* SharedPledgeViewStyles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedPledgeViewStyles.swift; sourceTree = "<group>"; };
39E436F62C88D7D2009707BE /* NoShippingConfirmDetailsViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoShippingConfirmDetailsViewModelTests.swift; sourceTree = "<group>"; };
3D1363951F0191FB00B53420 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
4705D8972742E20900A13BBE /* ProjectHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectHeaderCell.swift; sourceTree = "<group>"; };
471235F6274450AC0035527F /* ProjectPamphletMainCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProjectPamphletMainCell.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6503,6 +6505,7 @@
6021F66B2B97BCE200F76031 /* ConfirmDetailsViewModel.swift */,
6021F66D2B98AF0C00F76031 /* ConfirmDetailsViewModelTests.swift */,
6035AFBD2C598442007E28FC /* NoShippingConfirmDetailsViewModel.swift */,
39E436F62C88D7D2009707BE /* NoShippingConfirmDetailsViewModelTests.swift */,
373AB221222A058600769FC2 /* CreatePasswordViewModel.swift */,
373AB25A222A063500769FC2 /* CreatePasswordViewModelTests.swift */,
D63BBD36217FC224007E01F0 /* CreditCardCellViewModel.swift */,
Expand Down Expand Up @@ -8149,6 +8152,7 @@
3777F2F92343C7AB0030BEF5 /* ManageViewPledgeRewardReceivedViewModelTests.swift in Sources */,
47AC2139264AD5430090AEDF /* CommentsViewModelTests.swift in Sources */,
A7ED1FE31E831C5C00BFFA01 /* FindFriendsFaceookConnectCellViewModelTests.swift in Sources */,
39E436F72C88D7D2009707BE /* NoShippingConfirmDetailsViewModelTests.swift in Sources */,
A7ED1FFB1E831C5C00BFFA01 /* ProjectPamphletMainCellViewModelTests.swift in Sources */,
A7ED1FE41E831C5C00BFFA01 /* EmptyStatesViewModelTests.swift in Sources */,
D04AACA8218BB72100CF713E /* FindFriendsCellViewModelTests.swift in Sources */,
Expand Down
14 changes: 8 additions & 6 deletions Library/ViewModels/NoShippingConfirmDetailsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ public class NoShippingConfirmDetailsViewModel: NoShippingConfirmDetailsViewMode
calculatedShippingTotal
)

/// Initial pledge amount is zero if not backed.
let initialPledgeAmount = Signal.merge(
initialData.filter { $0.project.personalization.backing == nil }.mapConst(0.0),
backing.map(\.bonusAmount)
)
.take(first: 1)
/// If initial data includes a custom pledge amount, use that.
/// If not, bonus amount is 0 if there's no backing.
let initialPledgeAmount = Signal.zip(initialData.map(\.bonusSupport), project)
.map { bonusSupport, project in
if let bonusSupport { return bonusSupport }
if let backing = project.personalization.backing { return backing.bonusAmount }
return 0.0
}

/// Called when pledge or bonus is updated by backer
let additionalPledgeAmount = Signal.merge(
Expand Down
Loading