Skip to content

Commit

Permalink
Fix issue with default settings overwriting poll settings
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Oct 27, 2024
1 parent 2a97de9 commit 3cc797d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
alias(libs.plugins.kotlin.serialization) apply false
}
allprojects {
version = "5.7.1"
version = "5.7.2"
group = "space.votebot"

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ public data class FinalPollSettings(
/**
* Merges this instance of [PollSettings] with [other] to create a [FinalPollSettings] instance.
*/
public fun PollSettings.merge(other: PollSettings?): FinalPollSettings = FinalPollSettings(
deleteAfter ?: other?.deleteAfter,
(showChartAfterClose ?: other?.showChartAfterClose) != false,
maxVotes ?: other?.maxVotes ?: 1,
maxChanges ?: other?.maxChanges ?: 0,
(hideResults ?: other?.hideResults) == true,
(publicResults ?: other?.publicResults) == true,
emojiMode ?: other?.emojiMode ?: PollSettings.EmojiMode.ON
)
public fun PollSettings.merge(other: PollSettings?): FinalPollSettings {
return FinalPollSettings(
deleteAfter ?: other?.deleteAfter,
(showChartAfterClose ?: other?.showChartAfterClose) != false,
(maxVotes ?: other?.maxVotes ?: 1).takeIf { maxChanges == null || maxChanges == 1 } ?: 0,
(maxChanges ?: other?.maxChanges ?: 1).takeIf { maxVotes == null || maxVotes == 1 } ?: 0,
(hideResults ?: other?.hideResults) == true,
(publicResults ?: other?.publicResults) == true,
emojiMode ?: other?.emojiMode ?: PollSettings.EmojiMode.ON
)
}

0 comments on commit 3cc797d

Please sign in to comment.