Skip to content

Commit

Permalink
Merge pull request #1217 from wakmusic/1216-modify-standard-in-lyric-…
Browse files Browse the repository at this point in the history
…highlighting-line-cnt
  • Loading branch information
KangTaeHoon authored Aug 24, 2024
2 parents eb16844 + c026892 commit 27c4dbd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ public final class LyricHighlightingViewModel: ViewModelType {
.filter { $0 >= 0 }
.withLatestFrom(output.dataSource) { ($0, $1) }
.filter { index, entities in
guard entities[index].isHighlighting || entities.filter({ $0.isHighlighting }).count < 4 else {
let currentTotalLineCount: Int = entities.filter { $0.isHighlighting }
.map { $0.text.components(separatedBy: "\n").count }
.reduce(0, +)
let nowSelectItemLineCount: Int = entities[index].text
.components(separatedBy: "\n").count
guard entities[index].isHighlighting || (currentTotalLineCount + nowSelectItemLineCount <= 4) else {
output.showToast.onNext("가사는 최대 4줄까지 선택 가능합니다.")
return false
}
Expand Down

0 comments on commit 27c4dbd

Please sign in to comment.