Compare commits

...

3 Commits

Author SHA1 Message Date
60e689cca0 patch privacy settings 2025-10-08 03:16:34 +03:00
28ae309042 change names 2025-10-08 03:10:24 +03:00
dd5680742c patch editprivacy 2025-10-08 02:56:35 +03:00
4 changed files with 53 additions and 28 deletions

View File

@ -142,8 +142,17 @@ struct ProfilePermissionsRequestPayload: Encodable {
try container.encode(groupInvitePermission, forKey: .groupInvitePermission)
try container.encode(callPermission, forKey: .callPermission)
try container.encode(forceAutoDeleteMessagesInPrivate, forKey: .forceAutoDeleteMessagesInPrivate)
try container.encodeIfPresent(maxMessageAutoDeleteSeconds, forKey: .maxMessageAutoDeleteSeconds)
try container.encodeIfPresent(autoDeleteAfterDays, forKey: .autoDeleteAfterDays)
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)
}
}
}

View File

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

View File

@ -11,13 +11,6 @@ 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 },
@ -34,6 +27,22 @@ 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 {
@ -93,12 +102,16 @@ struct EditPrivacyView: View {
}
Section(header: Text("Чаты и хранение")) {
Toggle("Разрешить хранить чаты на сервере (Обычный)", isOn: $profilePermissions.allowServerChats)
Toggle("Принудительное автоудаление в ЛС (Приватный)", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
Toggle("Разрешить хранить чаты на сервере", isOn: $profilePermissions.allowServerChats)
}
Section(header: Text("Приватные чаты")) {
Toggle("Принудительное включение автоудаления сообщений", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
Toggle("Ограничить таймер автоудаления (максимум)", isOn: autoDeleteTimerEnabled)
if profilePermissions.forceAutoDeleteMessagesInPrivate {
Stepper(value: forceAutoDeleteBinding, in: 5...86400, step: 5) {
Text("Таймер автоудаления: \(formattedAutoDeleteSeconds(forceAutoDeleteBinding.wrappedValue))")
if autoDeleteTimerEnabled.wrappedValue {
Stepper(value: autoDeleteTimerBinding, in: 5...86400, step: 5) {
Text("Максимальное время автоудаления: \(formattedAutoDeleteSeconds(autoDeleteTimerBinding.wrappedValue))")
}
}
}
@ -153,13 +166,6 @@ struct EditPrivacyView: View {
)
}
.navigationTitle("Настройки приватности")
.onChange(of: profilePermissions.forceAutoDeleteMessagesInPrivate) { newValue in
if newValue {
profilePermissions.maxMessageAutoDeleteSeconds = profilePermissions.maxMessageAutoDeleteSeconds ?? 30
} else {
profilePermissions.maxMessageAutoDeleteSeconds = nil
}
}
.task {
await loadProfile()
}