mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 16:13:42 +02:00
vector-im/element-ios/issues/5114 - Various tweaks following PR review.
This commit is contained in:
committed by
Stefan Ceriu
parent
bf6ef2bce2
commit
d7e9fe61b4
@@ -21,7 +21,7 @@ typealias TimelinePollViewModelCallback = ((TimelinePollViewModelResult) -> Void
|
||||
|
||||
enum TimelinePollStateAction {
|
||||
case viewAction(TimelinePollViewAction, TimelinePollViewModelCallback?)
|
||||
case updateWithPoll(TimelinePoll)
|
||||
case updateWithPoll(TimelinePollDetails)
|
||||
case showAnsweringFailure
|
||||
case showClosingFailure
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class TimelinePollAnswerOption: Identifiable {
|
||||
}
|
||||
}
|
||||
|
||||
class TimelinePoll {
|
||||
class TimelinePollDetails {
|
||||
var question: String
|
||||
var answerOptions: [TimelinePollAnswerOption]
|
||||
var closed: Bool
|
||||
@@ -68,7 +68,8 @@ class TimelinePoll {
|
||||
closed: Bool,
|
||||
totalAnswerCount: UInt,
|
||||
type: TimelinePollType,
|
||||
maxAllowedSelections: UInt, hasBeenEdited: Bool) {
|
||||
maxAllowedSelections: UInt,
|
||||
hasBeenEdited: Bool) {
|
||||
self.question = question
|
||||
self.answerOptions = answerOptions
|
||||
self.closed = closed
|
||||
@@ -81,10 +82,18 @@ class TimelinePoll {
|
||||
var hasCurrentUserVoted: Bool {
|
||||
answerOptions.filter { $0.selected == true}.count > 0
|
||||
}
|
||||
|
||||
var shouldDiscloseResults: Bool {
|
||||
if closed {
|
||||
return totalAnswerCount > 0
|
||||
} else {
|
||||
return type == .disclosed && totalAnswerCount > 0 && hasCurrentUserVoted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TimelinePollViewState: BindableState {
|
||||
var poll: TimelinePoll
|
||||
var poll: TimelinePollDetails
|
||||
var bindings: TimelinePollViewStateBindings
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user