Made StateStoreViewModel state mutable and removed the reducer for all the features using it.

This commit is contained in:
Stefan Ceriu
2022-01-28 12:58:31 +02:00
committed by Stefan Ceriu
parent fc9e95aee8
commit 313b05485a
42 changed files with 324 additions and 431 deletions
@@ -19,13 +19,6 @@ import SwiftUI
typealias TimelinePollViewModelCallback = ((TimelinePollViewModelResult) -> Void)
enum TimelinePollStateAction {
case viewAction(TimelinePollViewAction, TimelinePollViewModelCallback?)
case updateWithPoll(TimelinePollDetails)
case showAnsweringFailure
case showClosingFailure
}
enum TimelinePollViewAction {
case selectAnswerOptionWithIdentifier(String)
}
@@ -39,7 +32,7 @@ enum TimelinePollType {
case undisclosed
}
class TimelinePollAnswerOption: Identifiable {
struct TimelinePollAnswerOption: Identifiable {
var id: String
var text: String
var count: UInt
@@ -55,7 +48,15 @@ class TimelinePollAnswerOption: Identifiable {
}
}
class TimelinePollDetails {
extension MutableCollection where Element == TimelinePollAnswerOption {
mutating func updateEach(_ update: (inout Element) -> Void) {
for index in indices {
update(&self[index])
}
}
}
struct TimelinePollDetails {
var question: String
var answerOptions: [TimelinePollAnswerOption]
var closed: Bool