Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok committed Feb 21, 2025
1 parent 5a7fbc1 commit 62cf2ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Core/Core/Data/Model/Data_UserProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ public enum AccountPrivacy: String, Codable, Sendable {
case privateAccess = "private"
case allUsers = "all_users"
case allUsersBig = "ALL_USERS"
case custom = "custom"

public var boolValue: Bool {
switch self {
case .privateAccess:
return false
case .allUsers, .allUsersBig:
case .allUsers, .allUsersBig, .custom:
return true
}
}
Expand Down
30 changes: 16 additions & 14 deletions Profile/Profile/Presentation/EditProfile/EditProfileViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class EditProfileViewModel: ObservableObject {
isShowProgress = true
do {
if try await interactor.deleteProfilePicture() {
inputImage = CoreAssets.noAvatar.image
// inputImage = CoreAssets.noAvatar.image
isShowProgress = false
}
} catch {
Expand Down Expand Up @@ -246,24 +246,14 @@ public class EditProfileViewModel: ObservableObject {
@MainActor
func uploadData(parameters: [String: any Any & Sendable]) async {
do {
if profileChanges.isAvatarDeleted {
if profileChanges.isAvatarDeleted || profileChanges.profileType == .limited {
try await deleteAvatar()
profileChanges.isAvatarChanged = false
profileChanges.isAvatarDeleted = false
profileChanges.isAvatarSaved = true
checkChanges()
}
if profileChanges.isAvatarChanged {
if let newImage = inputImage?.jpegData(compressionQuality: 80) {
isShowProgress = true
try await interactor.uploadProfilePicture(pictureData: newImage)
isShowProgress = false
profileChanges.isAvatarChanged = false
profileChanges.isAvatarSaved = true
checkChanges()
}
}

checkChanges()

if isChanged {
if !parameters.isEmpty {
isShowProgress = true
Expand All @@ -276,6 +266,18 @@ public class EditProfileViewModel: ObservableObject {
}
isChanged = false
}

if profileChanges.profileType == .full {
if let newImage = inputImage?.jpegData(compressionQuality: 80) {
isShowProgress = true
try await interactor.uploadProfilePicture(pictureData: newImage)
isShowProgress = false
profileChanges.isAvatarChanged = false
profileChanges.isAvatarSaved = true
checkChanges()
}
}

} catch {
isShowProgress = false
if error.isInternetError {
Expand Down

0 comments on commit 62cf2ad

Please sign in to comment.