Compare commits
3 Commits
06bdcac917
...
60e689cca0
| Author | SHA1 | Date | |
|---|---|---|---|
| 60e689cca0 | |||
| 28ae309042 | |||
| dd5680742c |
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -77,14 +77,18 @@ final class ProfileService {
|
||||
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")
|
||||
completion(.failure(ProfileServiceError.encoding(message)))
|
||||
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,
|
||||
|
||||
@ -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" : {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
if profilePermissions.forceAutoDeleteMessagesInPrivate {
|
||||
Stepper(value: forceAutoDeleteBinding, in: 5...86400, step: 5) {
|
||||
Text("Таймер автоудаления: \(formattedAutoDeleteSeconds(forceAutoDeleteBinding.wrappedValue))")
|
||||
Section(header: Text("Приватные чаты")) {
|
||||
Toggle("Принудительное включение автоудаления сообщений", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
|
||||
Toggle("Ограничить таймер автоудаления (максимум)", isOn: autoDeleteTimerEnabled)
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user