Compare commits

..

No commits in common. "60e689cca05be2142b3f921f822d8c19baee2e7e" and "06bdcac917881e6b9b2a5e9d0ea133a6738e869d" have entirely different histories.

4 changed files with 28 additions and 53 deletions

View File

@ -142,17 +142,8 @@ struct ProfilePermissionsRequestPayload: Encodable {
try container.encode(groupInvitePermission, forKey: .groupInvitePermission)
try container.encode(callPermission, forKey: .callPermission)
try container.encode(forceAutoDeleteMessagesInPrivate, forKey: .forceAutoDeleteMessagesInPrivate)
if let seconds = maxMessageAutoDeleteSeconds {
try container.encode(seconds, forKey: .maxMessageAutoDeleteSeconds)
} else {
try container.encodeNil(forKey: .maxMessageAutoDeleteSeconds)
}
if let days = autoDeleteAfterDays {
try container.encode(days, forKey: .autoDeleteAfterDays)
} else {
try container.encodeNil(forKey: .autoDeleteAfterDays)
}
try container.encodeIfPresent(maxMessageAutoDeleteSeconds, forKey: .maxMessageAutoDeleteSeconds)
try container.encodeIfPresent(autoDeleteAfterDays, forKey: .autoDeleteAfterDays)
}
}

View File

@ -76,6 +76,8 @@ final class ProfileService {
func updateProfile(_ payload: ProfileUpdateRequestPayload, completion: @escaping (Result<String, Error>) -> Void) {
let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase
print("payload \(payload)")
guard let body = try? encoder.encode(payload) else {
let message = NSLocalizedString("Не удалось подготовить данные запроса.", comment: "Profile update encoding error")
@ -83,12 +85,6 @@ final class ProfileService {
return
}
if let jsonString = String(data: body, encoding: .utf8) {
print("📤 Request Body JSON:\n\(jsonString)")
} else {
print("⚠️ Не удалось преобразовать тело запроса в строку")
}
client.request(
path: "/v1/profile/edit",
method: .put,

View File

@ -518,9 +518,6 @@
},
"Локальные чаты" : {
"comment" : "Local search section"
},
"Максимальное время автоудаления: %@" : {
},
"Мини-приложения" : {
"comment" : "Applets",
@ -829,9 +826,6 @@
},
"Обратная связь" : {
},
"Ограничить таймер автоудаления (максимум)" : {
},
"Описание" : {
@ -1077,9 +1071,6 @@
},
"Попробуйте изменить запрос поиска." : {
},
"Приватные чаты" : {
},
"Приглашение достигло лимита использования." : {
"localizations" : {
@ -1130,7 +1121,7 @@
"Принимать сообщения от незнакомцев" : {
},
"Принудительное включение автоудаления сообщений" : {
"Принудительное автоудаление в ЛС (Приватный)" : {
},
"Проверьте данные и повторите попытку." : {
@ -1181,7 +1172,7 @@
"Разрешить поиск профиля" : {
},
"Разрешить хранить чаты на сервере" : {
"Разрешить хранить чаты на сервере (Обычный)" : {
},
"Регистрация" : {
@ -1377,6 +1368,9 @@
}
}
}
},
"Таймер автоудаления: %@" : {
},
"Тёмная" : {
"localizations" : {

View File

@ -11,6 +11,13 @@ struct EditPrivacyView: View {
private var privacyScopeOptions: [PrivacyScope] { PrivacyScope.allCases }
private var forceAutoDeleteBinding: Binding<Int> {
Binding(
get: { profilePermissions.maxMessageAutoDeleteSeconds ?? 30 },
set: { profilePermissions.maxMessageAutoDeleteSeconds = $0 }
)
}
private var autoDeleteAccountEnabled: Binding<Bool> {
Binding(
get: { profilePermissions.autoDeleteAfterDays != nil },
@ -27,22 +34,6 @@ struct EditPrivacyView: View {
)
}
private var autoDeleteTimerEnabled: Binding<Bool> {
Binding(
get: { profilePermissions.maxMessageAutoDeleteSeconds != nil },
set: { newValue in
profilePermissions.maxMessageAutoDeleteSeconds = newValue ? (profilePermissions.maxMessageAutoDeleteSeconds ?? 30) : nil
}
)
}
private var autoDeleteTimerBinding: Binding<Int> {
Binding(
get: { profilePermissions.maxMessageAutoDeleteSeconds ?? 30 },
set: { profilePermissions.maxMessageAutoDeleteSeconds = min(max($0, 5), 86400) }
)
}
var body: some View {
Form {
if isLoading {
@ -102,16 +93,12 @@ struct EditPrivacyView: View {
}
Section(header: Text("Чаты и хранение")) {
Toggle("Разрешить хранить чаты на сервере", isOn: $profilePermissions.allowServerChats)
}
Section(header: Text("Приватные чаты")) {
Toggle("Принудительное включение автоудаления сообщений", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
Toggle("Ограничить таймер автоудаления (максимум)", isOn: autoDeleteTimerEnabled)
Toggle("Разрешить хранить чаты на сервере (Обычный)", isOn: $profilePermissions.allowServerChats)
Toggle("Принудительное автоудаление в ЛС (Приватный)", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
if autoDeleteTimerEnabled.wrappedValue {
Stepper(value: autoDeleteTimerBinding, in: 5...86400, step: 5) {
Text("Максимальное время автоудаления: \(formattedAutoDeleteSeconds(autoDeleteTimerBinding.wrappedValue))")
if profilePermissions.forceAutoDeleteMessagesInPrivate {
Stepper(value: forceAutoDeleteBinding, in: 5...86400, step: 5) {
Text("Таймер автоудаления: \(formattedAutoDeleteSeconds(forceAutoDeleteBinding.wrappedValue))")
}
}
}
@ -166,6 +153,13 @@ struct EditPrivacyView: View {
)
}
.navigationTitle("Настройки приватности")
.onChange(of: profilePermissions.forceAutoDeleteMessagesInPrivate) { newValue in
if newValue {
profilePermissions.maxMessageAutoDeleteSeconds = profilePermissions.maxMessageAutoDeleteSeconds ?? 30
} else {
profilePermissions.maxMessageAutoDeleteSeconds = nil
}
}
.task {
await loadProfile()
}