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(groupInvitePermission, forKey: .groupInvitePermission)
|
||||||
try container.encode(callPermission, forKey: .callPermission)
|
try container.encode(callPermission, forKey: .callPermission)
|
||||||
try container.encode(forceAutoDeleteMessagesInPrivate, forKey: .forceAutoDeleteMessagesInPrivate)
|
try container.encode(forceAutoDeleteMessagesInPrivate, forKey: .forceAutoDeleteMessagesInPrivate)
|
||||||
try container.encodeIfPresent(maxMessageAutoDeleteSeconds, forKey: .maxMessageAutoDeleteSeconds)
|
if let seconds = maxMessageAutoDeleteSeconds {
|
||||||
try container.encodeIfPresent(autoDeleteAfterDays, forKey: .autoDeleteAfterDays)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,8 +76,6 @@ final class ProfileService {
|
|||||||
func updateProfile(_ payload: ProfileUpdateRequestPayload, completion: @escaping (Result<String, Error>) -> Void) {
|
func updateProfile(_ payload: ProfileUpdateRequestPayload, completion: @escaping (Result<String, Error>) -> Void) {
|
||||||
let encoder = JSONEncoder()
|
let encoder = JSONEncoder()
|
||||||
encoder.keyEncodingStrategy = .convertToSnakeCase
|
encoder.keyEncodingStrategy = .convertToSnakeCase
|
||||||
|
|
||||||
print("payload \(payload)")
|
|
||||||
|
|
||||||
guard let body = try? encoder.encode(payload) else {
|
guard let body = try? encoder.encode(payload) else {
|
||||||
let message = NSLocalizedString("Не удалось подготовить данные запроса.", comment: "Profile update encoding error")
|
let message = NSLocalizedString("Не удалось подготовить данные запроса.", comment: "Profile update encoding error")
|
||||||
@ -85,6 +83,12 @@ final class ProfileService {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let jsonString = String(data: body, encoding: .utf8) {
|
||||||
|
print("📤 Request Body JSON:\n\(jsonString)")
|
||||||
|
} else {
|
||||||
|
print("⚠️ Не удалось преобразовать тело запроса в строку")
|
||||||
|
}
|
||||||
|
|
||||||
client.request(
|
client.request(
|
||||||
path: "/v1/profile/edit",
|
path: "/v1/profile/edit",
|
||||||
method: .put,
|
method: .put,
|
||||||
|
|||||||
@ -518,6 +518,9 @@
|
|||||||
},
|
},
|
||||||
"Локальные чаты" : {
|
"Локальные чаты" : {
|
||||||
"comment" : "Local search section"
|
"comment" : "Local search section"
|
||||||
|
},
|
||||||
|
"Максимальное время автоудаления: %@" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Мини-приложения" : {
|
"Мини-приложения" : {
|
||||||
"comment" : "Applets",
|
"comment" : "Applets",
|
||||||
@ -826,6 +829,9 @@
|
|||||||
},
|
},
|
||||||
"Обратная связь" : {
|
"Обратная связь" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Ограничить таймер автоудаления (максимум)" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Описание" : {
|
"Описание" : {
|
||||||
|
|
||||||
@ -1071,6 +1077,9 @@
|
|||||||
},
|
},
|
||||||
"Попробуйте изменить запрос поиска." : {
|
"Попробуйте изменить запрос поиска." : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Приватные чаты" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Приглашение достигло лимита использования." : {
|
"Приглашение достигло лимита использования." : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
@ -1121,7 +1130,7 @@
|
|||||||
"Принимать сообщения от незнакомцев" : {
|
"Принимать сообщения от незнакомцев" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Принудительное автоудаление в ЛС (Приватный)" : {
|
"Принудительное включение автоудаления сообщений" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Проверьте данные и повторите попытку." : {
|
"Проверьте данные и повторите попытку." : {
|
||||||
@ -1172,7 +1181,7 @@
|
|||||||
"Разрешить поиск профиля" : {
|
"Разрешить поиск профиля" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Разрешить хранить чаты на сервере (Обычный)" : {
|
"Разрешить хранить чаты на сервере" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Регистрация" : {
|
"Регистрация" : {
|
||||||
@ -1368,9 +1377,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"Таймер автоудаления: %@" : {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"Тёмная" : {
|
"Тёмная" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|||||||
@ -11,13 +11,6 @@ struct EditPrivacyView: View {
|
|||||||
|
|
||||||
private var privacyScopeOptions: [PrivacyScope] { PrivacyScope.allCases }
|
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> {
|
private var autoDeleteAccountEnabled: Binding<Bool> {
|
||||||
Binding(
|
Binding(
|
||||||
get: { profilePermissions.autoDeleteAfterDays != nil },
|
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 {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
if isLoading {
|
if isLoading {
|
||||||
@ -93,12 +102,16 @@ struct EditPrivacyView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Section(header: Text("Чаты и хранение")) {
|
Section(header: Text("Чаты и хранение")) {
|
||||||
Toggle("Разрешить хранить чаты на сервере (Обычный)", isOn: $profilePermissions.allowServerChats)
|
Toggle("Разрешить хранить чаты на сервере", isOn: $profilePermissions.allowServerChats)
|
||||||
Toggle("Принудительное автоудаление в ЛС (Приватный)", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
|
}
|
||||||
|
|
||||||
|
Section(header: Text("Приватные чаты")) {
|
||||||
|
Toggle("Принудительное включение автоудаления сообщений", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
|
||||||
|
Toggle("Ограничить таймер автоудаления (максимум)", isOn: autoDeleteTimerEnabled)
|
||||||
|
|
||||||
if profilePermissions.forceAutoDeleteMessagesInPrivate {
|
if autoDeleteTimerEnabled.wrappedValue {
|
||||||
Stepper(value: forceAutoDeleteBinding, in: 5...86400, step: 5) {
|
Stepper(value: autoDeleteTimerBinding, in: 5...86400, step: 5) {
|
||||||
Text("Таймер автоудаления: \(formattedAutoDeleteSeconds(forceAutoDeleteBinding.wrappedValue))")
|
Text("Максимальное время автоудаления: \(formattedAutoDeleteSeconds(autoDeleteTimerBinding.wrappedValue))")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,13 +166,6 @@ struct EditPrivacyView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
.navigationTitle("Настройки приватности")
|
.navigationTitle("Настройки приватности")
|
||||||
.onChange(of: profilePermissions.forceAutoDeleteMessagesInPrivate) { newValue in
|
|
||||||
if newValue {
|
|
||||||
profilePermissions.maxMessageAutoDeleteSeconds = profilePermissions.maxMessageAutoDeleteSeconds ?? 30
|
|
||||||
} else {
|
|
||||||
profilePermissions.maxMessageAutoDeleteSeconds = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.task {
|
.task {
|
||||||
await loadProfile()
|
await loadProfile()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user