Skip to content

Commit 3cc797d

Browse files
committed
Fix issue with default settings overwriting poll settings
1 parent 2a97de9 commit 3cc797d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
alias(libs.plugins.kotlin.serialization) apply false
66
}
77
allprojects {
8-
version = "5.7.1"
8+
version = "5.7.2"
99
group = "space.votebot"
1010

1111
repositories {

common/src/commonMain/kotlin/space/votebot/common/models/PollSettings.kt

+11-9
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ public data class FinalPollSettings(
8080
/**
8181
* Merges this instance of [PollSettings] with [other] to create a [FinalPollSettings] instance.
8282
*/
83-
public fun PollSettings.merge(other: PollSettings?): FinalPollSettings = FinalPollSettings(
84-
deleteAfter ?: other?.deleteAfter,
85-
(showChartAfterClose ?: other?.showChartAfterClose) != false,
86-
maxVotes ?: other?.maxVotes ?: 1,
87-
maxChanges ?: other?.maxChanges ?: 0,
88-
(hideResults ?: other?.hideResults) == true,
89-
(publicResults ?: other?.publicResults) == true,
90-
emojiMode ?: other?.emojiMode ?: PollSettings.EmojiMode.ON
91-
)
83+
public fun PollSettings.merge(other: PollSettings?): FinalPollSettings {
84+
return FinalPollSettings(
85+
deleteAfter ?: other?.deleteAfter,
86+
(showChartAfterClose ?: other?.showChartAfterClose) != false,
87+
(maxVotes ?: other?.maxVotes ?: 1).takeIf { maxChanges == null || maxChanges == 1 } ?: 0,
88+
(maxChanges ?: other?.maxChanges ?: 1).takeIf { maxVotes == null || maxVotes == 1 } ?: 0,
89+
(hideResults ?: other?.hideResults) == true,
90+
(publicResults ?: other?.publicResults) == true,
91+
emojiMode ?: other?.emojiMode ?: PollSettings.EmojiMode.ON
92+
)
93+
}

0 commit comments

Comments
 (0)