Skip to content

Commit cacb699

Browse files
Fix polls multiple answers minimum value (#898)
1 parent a9d0123 commit cacb699

File tree

8 files changed

+32
-14
lines changed

8 files changed

+32
-14
lines changed

.swiftformat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@
3333
--wraparguments before-first
3434
--wrapparameters before-first
3535
--wrapcollections before-first
36+
37+
# Exclude paths
38+
--exclude Sources/StreamChatSwiftUI/Generated,Sources/StreamChatSwiftUI/StreamSwiftyGif,Sources/StreamChatSwiftUI/StreamNuke

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
### ✅ Added
77
- Add support for showing current poll comment on alert [#891](https://github.com/GetStream/stream-chat-swiftui/pull/891)
88

9+
### 🐞 Fixed
10+
- Fix polls multiple answers minimum value being 1 instead of 2 [#898](https://github.com/GetStream/stream-chat-swiftui/pull/898)
11+
912
### 🔄 Changed
1013
- Make `ChatChannelInfoView` subviews public for creating custom info views through composition [#892](https://github.com/GetStream/stream-chat-swiftui/pull/892)
1114
- `ChannelTitleView`

Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public struct CreatePollView: View {
119119
if viewModel.multipleAnswers {
120120
HStack(alignment: .textFieldToggle) {
121121
VStack(alignment: .leading, spacing: 6) {
122-
Text(L10n.Composer.Polls.typeNumberFrom1And10)
122+
Text(L10n.Composer.Polls.typeNumberMinMaxRange)
123123
.foregroundColor(Color(colors.alert))
124124
.font(fonts.caption1)
125125
.offset(y: viewModel.showsMaxVotesError ? 0 : 6)

Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollViewModel.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CreatePollViewModel: ObservableObject {
7676
.map { text in
7777
guard !text.isEmpty else { return false }
7878
let intValue = Int(text) ?? 0
79-
return intValue < 1 || intValue > 10
79+
return intValue < 2 || intValue > 10
8080
}
8181
.combineLatest($maxVotesEnabled)
8282
.map { $0 && $1 }
@@ -132,6 +132,7 @@ class CreatePollViewModel: ObservableObject {
132132
guard optionsErrorIndices.isEmpty else { return false }
133133
guard !showsMaxVotesError else { return false }
134134
guard options.contains(where: { !$0.trimmed.isEmpty }) else { return false }
135+
guard !(maxVotesEnabled && maxVotes.trimmed.isEmpty) else { return false }
135136
return true
136137
}
137138

Sources/StreamChatSwiftUI/Generated/L10n.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ internal enum L10n {
275275
internal static var question: String { L10n.tr("Localizable", "composer.polls.question") }
276276
/// Suggest an option
277277
internal static var suggestOption: String { L10n.tr("Localizable", "composer.polls.suggest-option") }
278-
/// Type a number from 1 and 10
279-
internal static var typeNumberFrom1And10: String { L10n.tr("Localizable", "composer.polls.type-number-from-1-and-10") }
278+
/// Type a number from 2 and 10
279+
internal static var typeNumberMinMaxRange: String { L10n.tr("Localizable", "composer.polls.type-number-min-max-range") }
280280
}
281281
internal enum Quoted {
282282
/// Giphy

Sources/StreamChatSwiftUI/Resources/en.lproj/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"composer.polls.duplicate-option" = "This is already an option";
149149
"composer.polls.multiple-answers" = "Multiple answers";
150150
"composer.polls.suggest-option" = "Suggest an option";
151-
"composer.polls.type-number-from-1-and-10" = "Type a number from 1 and 10";
151+
"composer.polls.type-number-min-max-range" = "Type a number from 2 and 10";
152152
"composer.audio-recording.start" = "Start recording audio message";
153153
"composer.audio-recording.stop" = "Stop recording audio message";
154154

fastlane/Fastfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ desc 'Run source code formatting/linting'
497497
lane :run_swift_format do |options|
498498
Dir.chdir('..') do
499499
strict = options[:strict] ? '--lint' : nil
500-
sources_matrix[:swiftformat_include].each do |path|
501-
sh("mint run swiftformat #{strict} --config .swiftformat --exclude #{sources_matrix[:swiftformat_exclude].join(',')} #{path}")
500+
sources_matrix[:swiftformat].each do |path|
501+
sh("mint run swiftformat #{strict} --config .swiftformat #{path}")
502502
next if path.include?('Tests')
503503

504504
sh("mint run swiftlint lint --config .swiftlint.yml --fix --progress --quiet --reporter json #{path}") unless strict
@@ -532,8 +532,7 @@ lane :sources_matrix do
532532
size: ['Sources', xcode_project],
533533
sonar: ['Sources'],
534534
public_interface: ['Sources'],
535-
swiftformat_include: ['Sources', 'DemoAppSwiftUI', 'StreamChatSwiftUITests'],
536-
swiftformat_exclude: ['**/Generated', 'Sources/StreamChatSwiftUI/StreamNuke', 'Sources/StreamChatSwiftUI/StreamSwiftyGif']
535+
swiftformat: ['Sources', 'DemoAppSwiftUI', 'StreamChatSwiftUITests']
537536
}
538537
end
539538

lefthook.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
pre-commit:
22
parallel: false
33
jobs:
4-
- run: mint run swiftformat --config .swiftformat --exclude '**/Generated', 'Sources/StreamChatSwiftUI/StreamNuke', 'Sources/StreamChatSwiftUI/StreamSwiftyGif' {staged_files}
4+
- run: mint run swiftformat --config .swiftformat {staged_files}
55
glob: "*.{swift}"
66
stage_fixed: true
7+
exclude:
8+
- Sources/StreamChatSwiftUI/Generated/**
9+
- Sources/StreamChatSwiftUI/StreamNuke/**
10+
- Sources/StreamChatSwiftUI/StreamSwiftyGif/**
711
skip:
812
- merge
913
- rebase
1014

1115
- run: mint run swiftlint lint --config .swiftlint.yml --fix --progress --quiet --reporter json {staged_files}
1216
glob: "*.{swift}"
1317
stage_fixed: true
18+
exclude:
19+
- Sources/StreamChatSwiftUI/Generated/**
20+
- Sources/StreamChatSwiftUI/StreamNuke/**
21+
- Sources/StreamChatSwiftUI/StreamSwiftyGif/**
1422
skip:
1523
- merge
1624
- rebase
1725

18-
- run: mint run swiftlint lint --config .swiftlint.yml --strict --progress --quiet --reporter json {staged_files}
26+
pre-push:
27+
jobs:
28+
- run: mint run swiftlint lint --config .swiftlint.yml --strict --progress --quiet --reporter json {push_files}
1929
glob: "*.{swift}"
20-
stage_fixed: true
30+
exclude:
31+
- Sources/StreamChatSwiftUI/Generated/**
32+
- Sources/StreamChatSwiftUI/StreamNuke/**
33+
- Sources/StreamChatSwiftUI/StreamSwiftyGif/**
2134
skip:
22-
- merge
23-
- rebase
35+
- merge-commit

0 commit comments

Comments
 (0)