diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index b232543..55bad71 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -177,6 +177,9 @@ }, "Включить автоудаление аккаунта" : { + }, + "Включить ограничитель таймера автоудаления в ЛС" : { + }, "Вложение" : { @@ -826,6 +829,9 @@ }, "Обратная связь" : { + }, + "Ограничить таймер автоудаления (максимум): %@" : { + }, "Описание" : { @@ -1071,6 +1077,9 @@ }, "Попробуйте изменить запрос поиска." : { + }, + "Приватные чаты" : { + }, "Приглашение достигло лимита использования." : { "localizations" : { @@ -1121,7 +1130,7 @@ "Принимать сообщения от незнакомцев" : { }, - "Принудительное автоудаление в ЛС (Приватный)" : { + "Принудительное включение автоудаление сообщений" : { }, "Проверьте данные и повторите попытку." : { @@ -1172,7 +1181,7 @@ "Разрешить поиск профиля" : { }, - "Разрешить хранить чаты на сервере (Обычный)" : { + "Разрешить хранить чаты на сервере" : { }, "Регистрация" : { @@ -1368,9 +1377,6 @@ } } } - }, - "Таймер автоудаления: %@" : { - }, "Тёмная" : { "localizations" : { diff --git a/yobble/Views/Tab/Settings/EditPrivacyView.swift b/yobble/Views/Tab/Settings/EditPrivacyView.swift index 1115099..fca4dbc 100644 --- a/yobble/Views/Tab/Settings/EditPrivacyView.swift +++ b/yobble/Views/Tab/Settings/EditPrivacyView.swift @@ -11,13 +11,6 @@ struct EditPrivacyView: View { private var privacyScopeOptions: [PrivacyScope] { PrivacyScope.allCases } - private var forceAutoDeleteBinding: Binding { - Binding( - get: { profilePermissions.maxMessageAutoDeleteSeconds ?? 30 }, - set: { profilePermissions.maxMessageAutoDeleteSeconds = $0 } - ) - } - private var autoDeleteAccountEnabled: Binding { Binding( get: { profilePermissions.autoDeleteAfterDays != nil }, @@ -34,6 +27,22 @@ struct EditPrivacyView: View { ) } + private var autoDeleteTimerEnabled: Binding { + Binding( + get: { profilePermissions.maxMessageAutoDeleteSeconds != nil }, + set: { newValue in + profilePermissions.maxMessageAutoDeleteSeconds = newValue ? (profilePermissions.maxMessageAutoDeleteSeconds ?? 30) : nil + } + ) + } + + private var autoDeleteTimerBinding: Binding { + 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() }