File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Setting/Sources/Profile/ViewModel Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public enum SettingError: Error {
1313 case noBirthday
1414 case noAvailableBirthday
1515 case noAvailableNickname
16+ case tooManyMessage
1617 case overlappedNickname
1718 case failWithdrawAccount
1819 case noToken
@@ -30,6 +31,8 @@ extension SettingError: LocalizedError {
3031 return NSLocalizedString ( " 올바른 생년월일을 기입해주세요 " , comment: " Wrong Birthday " )
3132 case . noAvailableNickname:
3233 return NSLocalizedString ( " 1자 이상의 영문과 숫자조합으로 이루어진 닉네임을 기입해주세요 " , comment: " Wrond Nickname " )
34+ case . tooManyMessage:
35+ return NSLocalizedString ( " 30자 이하로 한 줄 소개를 적어주세요 " , comment: " Too Many Message " )
3336 case . overlappedNickname:
3437 return NSLocalizedString ( " 중복된 닉네임이에요 " , comment: " Overlapped Nickname " )
3538 case . failWithdrawAccount:
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ public final class ProfileSettingViewModel: ViewModelType {
3232 }
3333
3434 func didTapSaveButton( message: String ? ) {
35+ guard checkAvailableMessage ( message) else {
36+ return
37+ }
38+
3539 Task {
3640 do {
3741 var url : String ?
@@ -68,6 +72,7 @@ public final class ProfileSettingViewModel: ViewModelType {
6872
6973extension ProfileSettingViewModel {
7074 private func saveUserProfile( imageUrl: String ? , message: String ? ) {
75+ let message = message? . isEmpty == true ? nil : message
7176 Task {
7277 do {
7378 try await repository. updateUserProfile ( profilePictureUrl: imageUrl, message: message)
@@ -79,6 +84,14 @@ extension ProfileSettingViewModel {
7984 }
8085 }
8186
87+ private func checkAvailableMessage( _ message: String ? ) -> Bool {
88+ guard message? . count ?? 0 <= 30 else {
89+ currentState. send ( . showErrorAlert( SettingError . tooManyMessage) )
90+ return false
91+ }
92+ return true
93+ }
94+
8295 private func filenameFromFilepath( _ filepath: String ? ) -> String ? {
8396 guard let filepath = filepath else {
8497 return nil
You can’t perform that action at this time.
0 commit comments