mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Disable read privacy when status privacy is set to everyone
This commit is contained in:
@@ -58,6 +58,7 @@ private final class SelectivePrivacySettingsControllerArguments {
|
||||
let setPublicPhoto: (() -> Void)?
|
||||
let removePublicPhoto: (() -> Void)?
|
||||
let updateHideReadTime: ((Bool) -> Void)?
|
||||
let updateHideReadTimeDisabled: (() -> Void)?
|
||||
let openPremiumIntro: () -> Void
|
||||
|
||||
init(
|
||||
@@ -71,6 +72,7 @@ private final class SelectivePrivacySettingsControllerArguments {
|
||||
setPublicPhoto: (() -> Void)?,
|
||||
removePublicPhoto: (() -> Void)?,
|
||||
updateHideReadTime: ((Bool) -> Void)?,
|
||||
updateHideReadTimeDisabled: (() -> Void)?,
|
||||
openPremiumIntro: @escaping () -> Void
|
||||
) {
|
||||
self.context = context
|
||||
@@ -83,6 +85,7 @@ private final class SelectivePrivacySettingsControllerArguments {
|
||||
self.setPublicPhoto = setPublicPhoto
|
||||
self.removePublicPhoto = removePublicPhoto
|
||||
self.updateHideReadTime = updateHideReadTime
|
||||
self.updateHideReadTimeDisabled = updateHideReadTimeDisabled
|
||||
self.openPremiumIntro = openPremiumIntro
|
||||
}
|
||||
}
|
||||
@@ -138,7 +141,7 @@ private enum SelectivePrivacySettingsEntry: ItemListNodeEntry {
|
||||
case phoneDiscoveryEverybody(PresentationTheme, String, Bool)
|
||||
case phoneDiscoveryMyContacts(PresentationTheme, String, Bool)
|
||||
case phoneDiscoveryInfo(PresentationTheme, String, String)
|
||||
case hideReadTime(PresentationTheme, String, Bool)
|
||||
case hideReadTime(PresentationTheme, String, Bool, Bool)
|
||||
case hideReadTimeInfo(PresentationTheme, String)
|
||||
case subscribeToPremium(PresentationTheme, String)
|
||||
case subscribeToPremiumInfo(PresentationTheme, String)
|
||||
@@ -410,8 +413,8 @@ private enum SelectivePrivacySettingsEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .hideReadTime(lhsTheme, lhsText, lhsValue):
|
||||
if case let .hideReadTime(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue {
|
||||
case let .hideReadTime(lhsTheme, lhsText, lhsEnabled, lhsValue):
|
||||
if case let .hideReadTime(rhsTheme, rhsText, rhsEnabled, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsEnabled == rhsEnabled, lhsValue == rhsValue {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -535,9 +538,11 @@ private enum SelectivePrivacySettingsEntry: ItemListNodeEntry {
|
||||
case let .publicPhotoInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section, linkAction: { _ in
|
||||
})
|
||||
case let .hideReadTime(_, text, value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
||||
case let .hideReadTime(_, text, enabled, value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, enabled: enabled, sectionId: self.section, style: .blocks, updated: { value in
|
||||
arguments.updateHideReadTime?(value)
|
||||
}, activatedWhileDisabled: {
|
||||
arguments.updateHideReadTimeDisabled?()
|
||||
})
|
||||
case let .hideReadTimeInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
@@ -847,7 +852,14 @@ private func selectivePrivacySettingsControllerEntries(presentationData: Present
|
||||
}
|
||||
|
||||
if case .presence = kind, let peer {
|
||||
entries.append(.hideReadTime(presentationData.theme, presentationData.strings.Settings_Privacy_ReadTime, state.hideReadTimeEnabled == true))
|
||||
let isEnabled: Bool
|
||||
switch state.setting {
|
||||
case .everybody:
|
||||
isEnabled = false
|
||||
default:
|
||||
isEnabled = true
|
||||
}
|
||||
entries.append(.hideReadTime(presentationData.theme, presentationData.strings.Settings_Privacy_ReadTime, isEnabled, isEnabled && state.hideReadTimeEnabled == true))
|
||||
entries.append(.hideReadTimeInfo(presentationData.theme, presentationData.strings.Settings_Privacy_ReadTimeFooter))
|
||||
|
||||
if !peer.isPremium {
|
||||
@@ -1164,6 +1176,9 @@ func selectivePrivacySettingsController(
|
||||
updateState { state in
|
||||
return state.withUpdatedHideReadTimeEnabled(value)
|
||||
}
|
||||
}, updateHideReadTimeDisabled: {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.PrivacyInfo_ShowReadTime_AlwaysToast_Text, timeout: nil, customUndoText: nil), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil)
|
||||
}, openPremiumIntro: {
|
||||
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .presence, forceDark: false, dismissed: nil)
|
||||
pushControllerImpl?(controller, true)
|
||||
@@ -1353,7 +1368,18 @@ func selectivePrivacySettingsController(
|
||||
(controller?.navigationController as? NavigationController)?.pushViewController(c, animated: animated)
|
||||
}
|
||||
presentControllerImpl = { [weak controller] c, a in
|
||||
controller?.present(c, in: .window(.root), with: a)
|
||||
if c is UndoOverlayController {
|
||||
controller?.forEachController { other in
|
||||
if let other = other as? UndoOverlayController {
|
||||
other.dismiss()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
controller?.present(c, in: .current, with: a)
|
||||
} else {
|
||||
controller?.present(c, in: .window(.root), with: a)
|
||||
}
|
||||
}
|
||||
|
||||
return controller
|
||||
|
||||
Reference in New Issue
Block a user