Skip to content

Commit

Permalink
convert id to string in project page view model
Browse files Browse the repository at this point in the history
  • Loading branch information
scottkicks committed Dec 4, 2023
1 parent 4f645e8 commit 0e58684
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ public final class ProjectPageViewController: UIViewController, MessageBannerVie
private func presentBlockUserAlert(username: String, userId: Int) {
let alert = UIAlertController
.blockUserAlert(username: username, blockUserHandler: { _ in
self.viewModel.inputs.blockUser(id: "\(userId)")
self.viewModel.inputs.blockUser(id: userId)
})

self.present(alert, animated: true)
Expand Down
8 changes: 4 additions & 4 deletions Library/ViewModels/ProjectPageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public protocol ProjectPageViewModelInputs {
func applicationDidEnterBackground()

/// Call when block user is tapped
func blockUser(id: String)
func blockUser(id: Int)

/// Call with the project given to the view controller.
func configureWith(projectOrParam: Either<Project, Param>, refTag: RefTag?)
Expand Down Expand Up @@ -506,7 +506,7 @@ public final class ProjectPageViewModel: ProjectPageViewModelType, ProjectPageVi
self.goToURL = self.didSelectCampaignImageLinkProperty.signal.skipNil()

let blockUserEvent = self.blockUserProperty.signal
.map(BlockUserInput.init(blockUserId:))
.map { BlockUserInput.init(blockUserId: "\($0)") }
.switchMap { input in
AppEnvironment.current.apiService
.blockUser(input: input)
Expand All @@ -531,8 +531,8 @@ public final class ProjectPageViewModel: ProjectPageViewModelType, ProjectPageVi
self.applicationDidEnterBackgroundProperty.value = ()
}

fileprivate let blockUserProperty = MutableProperty<String>("")
public func blockUser(id: String) {
fileprivate let blockUserProperty = MutableProperty<Int>(0)
public func blockUser(id: Int) {
self.blockUserProperty.value = id
}

Expand Down
4 changes: 2 additions & 2 deletions Library/ViewModels/ProjectPageViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ final class ProjectPageViewModelTests: TestCase {
self.didBlockUser.assertValueCount(0)
self.didBlockUserError.assertValueCount(0)

self.vm.inputs.blockUser(id: "\(User.template.id)")
self.vm.inputs.blockUser(id: User.template.id)

self.scheduler.advance()

Expand All @@ -355,7 +355,7 @@ final class ProjectPageViewModelTests: TestCase {
self.didBlockUser.assertValueCount(0)
self.didBlockUserError.assertValueCount(0)

self.vm.inputs.blockUser(id: "\(User.template.id)")
self.vm.inputs.blockUser(id: User.template.id)

self.scheduler.advance()

Expand Down

0 comments on commit 0e58684

Please sign in to comment.