mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add gift auto save privacy
This commit is contained in:
parent
6513887eed
commit
d776dc0597
@ -13231,3 +13231,14 @@ Sorry for the inconvenience.";
|
||||
|
||||
"Notification.StarGift.Bot.Subtitle" = "Display this gift on your page.";
|
||||
"Notification.StarGift.Bot.Subtitle.Displaying" = "You are displaying this gift on your page.";
|
||||
|
||||
"Privacy.Gifts" = "Gifts";
|
||||
"Privacy.Gifts.WhoCanSeeMyBio" = "WHO CAN DISPLAY GIFTS ON MY PROFILE";
|
||||
"Privacy.Gifts.CustomHelp" = "Choose whether gifts from specific senders need your approval before they’re visible to others on your profile.";
|
||||
"Privacy.Gifts.AlwaysAllow.Title" = "Always Allow";
|
||||
"Privacy.Gifts.NeverAllow.Title" = "Never Allow";
|
||||
|
||||
"PrivacySettings.ValueBots" = "Mini Apps";
|
||||
"PrivacySettings.ValueBotsPlus" = "Mini Apps +%@";
|
||||
|
||||
"PrivacySettings.CategoryBots" = "Mini Apps";
|
||||
|
@ -165,4 +165,5 @@ public enum SelectivePrivacySettingsKind {
|
||||
case voiceMessages
|
||||
case bio
|
||||
case birthday
|
||||
case giftsAutoSave
|
||||
}
|
||||
|
@ -223,8 +223,12 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
|
||||
func safeInsets(inLandscape: Bool) -> UIEdgeInsets {
|
||||
switch self {
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhoneXr, .iPhone12Mini, .iPhone12, .iPhone12ProMax, .iPhone13Mini, .iPhone13, .iPhone13Pro, .iPhone13ProMax, .iPhone14Pro, .iPhone14ProZoomed, .iPhone14ProMax, .iPhone14ProMaxZoomed, .iPhone16Pro, .iPhone16ProMax:
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhoneXr, .iPhone14ProZoomed, .iPhone14ProMaxZoomed:
|
||||
return inLandscape ? UIEdgeInsets(top: 0.0, left: 44.0, bottom: 0.0, right: 44.0) : UIEdgeInsets(top: 44.0, left: 0.0, bottom: 0.0, right: 0.0)
|
||||
case .iPhone12Mini, .iPhone12, .iPhone12ProMax, .iPhone13Mini, .iPhone13, .iPhone13Pro, .iPhone13ProMax:
|
||||
return inLandscape ? UIEdgeInsets(top: 0.0, left: 47.0, bottom: 0.0, right: 47.0) : UIEdgeInsets(top: 44.0, left: 0.0, bottom: 0.0, right: 0.0)
|
||||
case .iPhone14Pro, .iPhone14ProMax, .iPhone16Pro, .iPhone16ProMax:
|
||||
return inLandscape ? UIEdgeInsets(top: 0.0, left: 59.0, bottom: 0.0, right: 59.0) : UIEdgeInsets(top: 44.0, left: 0.0, bottom: 0.0, right: 0.0)
|
||||
default:
|
||||
return UIEdgeInsets.zero
|
||||
}
|
||||
|
@ -41,8 +41,9 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
let openDataSettings: () -> Void
|
||||
let openEmailSettings: (String?) -> Void
|
||||
let openMessagePrivacy: () -> Void
|
||||
let openGiftsPrivacy: () -> Void
|
||||
|
||||
init(account: Account, openBlockedUsers: @escaping () -> Void, openLastSeenPrivacy: @escaping () -> Void, openGroupsPrivacy: @escaping () -> Void, openVoiceCallPrivacy: @escaping () -> Void, openProfilePhotoPrivacy: @escaping () -> Void, openForwardPrivacy: @escaping () -> Void, openPhoneNumberPrivacy: @escaping () -> Void, openVoiceMessagePrivacy: @escaping () -> Void, openBioPrivacy: @escaping () -> Void, openBirthdayPrivacy: @escaping () -> Void, openPasscode: @escaping () -> Void, openTwoStepVerification: @escaping (TwoStepVerificationAccessConfiguration?) -> Void, openActiveSessions: @escaping () -> Void, toggleArchiveAndMuteNonContacts: @escaping (Bool) -> Void, setupAccountAutoremove: @escaping () -> Void, setupMessageAutoremove: @escaping () -> Void, openDataSettings: @escaping () -> Void, openEmailSettings: @escaping (String?) -> Void, openMessagePrivacy: @escaping () -> Void) {
|
||||
init(account: Account, openBlockedUsers: @escaping () -> Void, openLastSeenPrivacy: @escaping () -> Void, openGroupsPrivacy: @escaping () -> Void, openVoiceCallPrivacy: @escaping () -> Void, openProfilePhotoPrivacy: @escaping () -> Void, openForwardPrivacy: @escaping () -> Void, openPhoneNumberPrivacy: @escaping () -> Void, openVoiceMessagePrivacy: @escaping () -> Void, openBioPrivacy: @escaping () -> Void, openBirthdayPrivacy: @escaping () -> Void, openPasscode: @escaping () -> Void, openTwoStepVerification: @escaping (TwoStepVerificationAccessConfiguration?) -> Void, openActiveSessions: @escaping () -> Void, toggleArchiveAndMuteNonContacts: @escaping (Bool) -> Void, setupAccountAutoremove: @escaping () -> Void, setupMessageAutoremove: @escaping () -> Void, openDataSettings: @escaping () -> Void, openEmailSettings: @escaping (String?) -> Void, openMessagePrivacy: @escaping () -> Void, openGiftsPrivacy: @escaping () -> Void) {
|
||||
self.account = account
|
||||
self.openBlockedUsers = openBlockedUsers
|
||||
self.openLastSeenPrivacy = openLastSeenPrivacy
|
||||
@ -63,6 +64,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
self.openDataSettings = openDataSettings
|
||||
self.openEmailSettings = openEmailSettings
|
||||
self.openMessagePrivacy = openMessagePrivacy
|
||||
self.openGiftsPrivacy = openGiftsPrivacy
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,6 +106,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
case messagePrivacy(PresentationTheme, Bool, Bool)
|
||||
case bioPrivacy(PresentationTheme, String, String)
|
||||
case birthdayPrivacy(PresentationTheme, String, String)
|
||||
case giftsAutoSavePrivacy(PresentationTheme, String, String)
|
||||
case selectivePrivacyInfo(PresentationTheme, String)
|
||||
case passcode(PresentationTheme, String, Bool, String)
|
||||
case twoStepVerification(PresentationTheme, String, String, TwoStepVerificationAccessConfiguration?)
|
||||
@ -127,7 +130,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return PrivacyAndSecuritySection.general.rawValue
|
||||
case .loginEmail, .loginEmailInfo:
|
||||
return PrivacyAndSecuritySection.loginEmail.rawValue
|
||||
case .privacyHeader, .phoneNumberPrivacy, .lastSeenPrivacy, .profilePhotoPrivacy, .forwardPrivacy, .groupPrivacy, .groupPrivacyFooter, .voiceCallPrivacy, .voiceMessagePrivacy, .messagePrivacy, .bioPrivacy, .birthdayPrivacy, .selectivePrivacyInfo:
|
||||
case .privacyHeader, .phoneNumberPrivacy, .lastSeenPrivacy, .profilePhotoPrivacy, .forwardPrivacy, .groupPrivacy, .groupPrivacyFooter, .voiceCallPrivacy, .voiceMessagePrivacy, .messagePrivacy, .bioPrivacy, .birthdayPrivacy, .giftsAutoSavePrivacy, .selectivePrivacyInfo:
|
||||
return PrivacyAndSecuritySection.privacy.rawValue
|
||||
case .autoArchiveHeader, .autoArchive, .autoArchiveInfo:
|
||||
return PrivacyAndSecuritySection.autoArchive.rawValue
|
||||
@ -168,10 +171,12 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return 13
|
||||
case .birthdayPrivacy:
|
||||
return 14
|
||||
case .forwardPrivacy:
|
||||
case .giftsAutoSavePrivacy:
|
||||
return 15
|
||||
case .voiceCallPrivacy:
|
||||
case .forwardPrivacy:
|
||||
return 16
|
||||
case .voiceCallPrivacy:
|
||||
return 17
|
||||
case .voiceMessagePrivacy:
|
||||
return 18
|
||||
case .messagePrivacy:
|
||||
@ -281,6 +286,12 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .giftsAutoSavePrivacy(lhsTheme, lhsText, lhsValue):
|
||||
if case let .giftsAutoSavePrivacy(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .selectivePrivacyInfo(lhsTheme, lhsText):
|
||||
if case let .selectivePrivacyInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
@ -431,6 +442,10 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openBirthdayPrivacy()
|
||||
})
|
||||
case let .giftsAutoSavePrivacy(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openGiftsPrivacy()
|
||||
})
|
||||
case let .selectivePrivacyInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .voiceCallPrivacy(_, text, value):
|
||||
@ -504,8 +519,8 @@ private func countForSelectivePeers(_ peers: [PeerId: SelectivePrivacyPeer]) ->
|
||||
|
||||
private func stringForSelectiveSettings(strings: PresentationStrings, settings: SelectivePrivacySettings) -> String {
|
||||
switch settings {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
||||
if enableFor.isEmpty && !enableForCloseFriends && !enableForPremium {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||
if enableFor.isEmpty && !enableForCloseFriends && !enableForPremium && !enableForBots {
|
||||
return strings.PrivacySettings_LastSeenNobody
|
||||
} else {
|
||||
if enableForCloseFriends && enableForPremium {
|
||||
@ -520,6 +535,12 @@ private func stringForSelectiveSettings(strings: PresentationStrings, settings:
|
||||
} else {
|
||||
return strings.PrivacySettings_ValuePremiumPlus("\(countForSelectivePeers(enableFor))").string
|
||||
}
|
||||
} else if enableForBots {
|
||||
if enableFor.isEmpty {
|
||||
return strings.PrivacySettings_ValueBots
|
||||
} else {
|
||||
return strings.PrivacySettings_ValueBotsPlus("\(countForSelectivePeers(enableFor))").string
|
||||
}
|
||||
} else if enableForCloseFriends {
|
||||
if enableFor.isEmpty {
|
||||
return strings.PrivacySettings_LastSeenCloseFriendsPlus("\(countForSelectivePeers(enableFor))").string
|
||||
@ -540,9 +561,11 @@ private func stringForSelectiveSettings(strings: PresentationStrings, settings:
|
||||
} else {
|
||||
return strings.PrivacySettings_LastSeenEverybodyMinus("\(countForSelectivePeers(disableFor))").string
|
||||
}
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||
if enableForPremium {
|
||||
return strings.PrivacySettings_ValuePremiumAndContacts
|
||||
} else if enableForBots {
|
||||
return strings.PrivacySettings_ValueBots
|
||||
} else {
|
||||
if !enableFor.isEmpty && !disableFor.isEmpty {
|
||||
return strings.PrivacySettings_LastSeenContactsMinusPlus("\(countForSelectivePeers(disableFor))", "\(countForSelectivePeers(enableFor))").string
|
||||
@ -633,6 +656,7 @@ private func privacyAndSecurityControllerEntries(
|
||||
entries.append(.profilePhotoPrivacy(presentationData.theme, presentationData.strings.Privacy_ProfilePhoto, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.profilePhoto)))
|
||||
entries.append(.bioPrivacy(presentationData.theme, presentationData.strings.Privacy_Bio, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.bio)))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.birthday)))
|
||||
entries.append(.giftsAutoSavePrivacy(presentationData.theme, presentationData.strings.Privacy_Gifts, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.giftsAutoSave)))
|
||||
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.forwards)))
|
||||
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceCalls)))
|
||||
if !isPremiumDisabled {
|
||||
@ -647,13 +671,14 @@ private func privacyAndSecurityControllerEntries(
|
||||
entries.append(.profilePhotoPrivacy(presentationData.theme, presentationData.strings.Privacy_ProfilePhoto, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.bioPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.giftsAutoSavePrivacy(presentationData.theme, presentationData.strings.Privacy_Gifts, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.groupPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, presentationData.strings.Channel_NotificationLoading))
|
||||
if !isPremiumDisabled {
|
||||
entries.append(.voiceMessagePrivacy(presentationData.theme, presentationData.strings.Privacy_VoiceMessages, presentationData.strings.Channel_NotificationLoading, isPremium))
|
||||
}
|
||||
|
||||
entries.append(.groupPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.groupPrivacyFooter)
|
||||
//entries.append(.selectivePrivacyInfo(presentationData.theme, presentationData.strings.PrivacyLastSeenSettings_GroupsAndChannelsHelp))
|
||||
}
|
||||
|
||||
@ -844,7 +869,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: updated, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: updatedGlobalSettings ?? value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: updated, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: updatedGlobalSettings ?? value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -867,7 +892,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: updated, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: updated, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -904,7 +929,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: updated, voiceCallsP2P: updatedCallsPrivacy, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: updated, voiceCallsP2P: updatedCallsPrivacy, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -931,7 +956,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: updated, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: updated, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -954,7 +979,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: updated, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: updated, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -977,7 +1002,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: updated, phoneDiscoveryEnabled: updatedDiscoveryEnabled ?? value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: updated, phoneDiscoveryEnabled: updatedDiscoveryEnabled ?? value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1003,7 +1028,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: updated, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: updated, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1026,7 +1051,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: updated, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: updated, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1049,7 +1074,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: updated, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: updated, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1117,7 +1142,7 @@ public func privacyAndSecurityController(
|
||||
var globalSettings = value.globalSettings
|
||||
globalSettings.automaticallyArchiveAndMuteNonContacts = archiveValue
|
||||
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1156,7 +1181,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: timeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: timeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1219,7 +1244,7 @@ public func privacyAndSecurityController(
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: updatedValue == 0 ? nil : updatedValue)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: updatedValue == 0 ? nil : updatedValue)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1269,7 +1294,7 @@ public func privacyAndSecurityController(
|
||||
var globalSettings = value.globalSettings
|
||||
globalSettings.nonContactChatsRequirePremium = settingValue
|
||||
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, globalSettings: globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -1286,6 +1311,29 @@ public func privacyAndSecurityController(
|
||||
}))
|
||||
}), true)
|
||||
})
|
||||
}, openGiftsPrivacy: {
|
||||
let signal = privacySettingsPromise.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
currentInfoDisposable.set(signal.start(next: { [weak currentInfoDisposable] info in
|
||||
if let info = info {
|
||||
pushControllerImpl?(selectivePrivacySettingsController(context: context, kind: .giftsAutoSave, current: info.giftsAutoSave, updated: { updated, _, updatedDiscoveryEnabled, _ in
|
||||
if let currentInfoDisposable = currentInfoDisposable {
|
||||
let applySetting: Signal<Void, NoError> = privacySettingsPromise.get()
|
||||
|> filter { $0 != nil }
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: value.birthday, giftsAutoSave: updated, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
currentInfoDisposable.set(applySetting.start())
|
||||
}
|
||||
}), true)
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
actionsDisposable.add(context.engine.peers.managedUpdatedRecentPeers().start())
|
||||
|
@ -96,8 +96,8 @@ private enum SelectivePrivacySettingsSection: Int32 {
|
||||
case premium
|
||||
}
|
||||
|
||||
private func stringForUserCount(_ peers: [EnginePeer.Id: SelectivePrivacyPeer], enableForPremium: Bool, strings: PresentationStrings) -> String {
|
||||
if peers.isEmpty && !enableForPremium {
|
||||
private func stringForUserCount(_ peers: [EnginePeer.Id: SelectivePrivacyPeer], enableForPremium: Bool, enableForBots: Bool, strings: PresentationStrings) -> String {
|
||||
if peers.isEmpty && !enableForPremium && !enableForBots {
|
||||
return strings.PrivacyLastSeenSettings_EmpryUsersPlaceholder
|
||||
} else {
|
||||
var result = 0
|
||||
@ -105,7 +105,13 @@ private func stringForUserCount(_ peers: [EnginePeer.Id: SelectivePrivacyPeer],
|
||||
result += peer.userCount
|
||||
}
|
||||
|
||||
if enableForPremium {
|
||||
if enableForBots {
|
||||
if result == 0 {
|
||||
return strings.PrivacySettings_ValueBots
|
||||
} else {
|
||||
return strings.PrivacySettings_ValueBotsPlus("\(result)").string
|
||||
}
|
||||
} else if enableForPremium {
|
||||
if result == 0 {
|
||||
return strings.PrivacySettings_ValuePremium
|
||||
} else {
|
||||
@ -588,6 +594,7 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
||||
let enableForPremium: Bool
|
||||
let disableFor: [EnginePeer.Id: SelectivePrivacyPeer]
|
||||
let enableForCloseFriends: Bool
|
||||
let enableForBots: Bool
|
||||
|
||||
let saving: Bool
|
||||
|
||||
@ -603,12 +610,13 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
||||
|
||||
let uploadedPhoto: UIImage?
|
||||
|
||||
init(setting: SelectivePrivacySettingType, enableFor: [EnginePeer.Id: SelectivePrivacyPeer], enableForPremium: Bool, disableFor: [EnginePeer.Id: SelectivePrivacyPeer], enableForCloseFriends: Bool, saving: Bool, callDataSaving: VoiceCallDataSaving?, callP2PMode: SelectivePrivacySettingType?, callP2PEnableFor: [EnginePeer.Id: SelectivePrivacyPeer]?, callP2PDisableFor: [EnginePeer.Id: SelectivePrivacyPeer]?, callP2PEnableForCloseFriends: Bool?, callIntegrationAvailable: Bool?, callIntegrationEnabled: Bool?, phoneDiscoveryEnabled: Bool?, hideReadTimeEnabled: Bool?, uploadedPhoto: UIImage?) {
|
||||
init(setting: SelectivePrivacySettingType, enableFor: [EnginePeer.Id: SelectivePrivacyPeer], enableForPremium: Bool, disableFor: [EnginePeer.Id: SelectivePrivacyPeer], enableForCloseFriends: Bool, enableForBots: Bool, saving: Bool, callDataSaving: VoiceCallDataSaving?, callP2PMode: SelectivePrivacySettingType?, callP2PEnableFor: [EnginePeer.Id: SelectivePrivacyPeer]?, callP2PDisableFor: [EnginePeer.Id: SelectivePrivacyPeer]?, callP2PEnableForCloseFriends: Bool?, callIntegrationAvailable: Bool?, callIntegrationEnabled: Bool?, phoneDiscoveryEnabled: Bool?, hideReadTimeEnabled: Bool?, uploadedPhoto: UIImage?) {
|
||||
self.setting = setting
|
||||
self.enableFor = enableFor
|
||||
self.enableForPremium = enableForPremium
|
||||
self.disableFor = disableFor
|
||||
self.enableForCloseFriends = enableForCloseFriends
|
||||
self.enableForBots = enableForBots
|
||||
self.saving = saving
|
||||
self.callDataSaving = callDataSaving
|
||||
self.callP2PMode = callP2PMode
|
||||
@ -638,6 +646,9 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
||||
if lhs.enableForCloseFriends != rhs.enableForCloseFriends {
|
||||
return false
|
||||
}
|
||||
if lhs.enableForBots != rhs.enableForBots {
|
||||
return false
|
||||
}
|
||||
if lhs.saving != rhs.saving {
|
||||
return false
|
||||
}
|
||||
@ -676,59 +687,63 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
||||
}
|
||||
|
||||
func withUpdatedSetting(_ setting: SelectivePrivacySettingType) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedEnableFor(_ enableFor: [EnginePeer.Id: SelectivePrivacyPeer]) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedEnableForPremium(_ value: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: value, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: value, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedDisableFor(_ disableFor: [EnginePeer.Id: SelectivePrivacyPeer]) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedEnableForCloseFriends(_ enableForCloseFriends: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedEnableForBots(_ enableForBots: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedSaving(_ saving: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedCallP2PMode(_ mode: SelectivePrivacySettingType) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: mode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: mode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedCallP2PEnableFor(_ enableFor: [EnginePeer.Id: SelectivePrivacyPeer]) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: enableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: enableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedCallP2PDisableFor(_ disableFor: [EnginePeer.Id: SelectivePrivacyPeer]) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: disableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: disableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedCallP2PEnableForCloseFriends(_ callP2PEnableForCloseFriends: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedCallsIntegrationEnabled(_ enabled: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: enabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: enabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedPhoneDiscoveryEnabled(_ phoneDiscoveryEnabled: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedUploadedPhoto(_ uploadedPhoto: UIImage?) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: self.hideReadTimeEnabled, uploadedPhoto: uploadedPhoto)
|
||||
}
|
||||
|
||||
func withUpdatedHideReadTimeEnabled(_ hideReadTimeEnabled: Bool) -> SelectivePrivacySettingsControllerState {
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
return SelectivePrivacySettingsControllerState(setting: self.setting, enableFor: self.enableFor, enableForPremium: self.enableForPremium, disableFor: self.disableFor, enableForCloseFriends: self.enableForCloseFriends, enableForBots: self.enableForBots, saving: self.saving, callDataSaving: self.callDataSaving, callP2PMode: self.callP2PMode, callP2PEnableFor: self.callP2PEnableFor, callP2PDisableFor: self.callP2PDisableFor, callP2PEnableForCloseFriends: self.callP2PEnableForCloseFriends, callIntegrationAvailable: self.callIntegrationAvailable, callIntegrationEnabled: self.callIntegrationEnabled, phoneDiscoveryEnabled: self.phoneDiscoveryEnabled, hideReadTimeEnabled: hideReadTimeEnabled, uploadedPhoto: self.uploadedPhoto)
|
||||
}
|
||||
|
||||
}
|
||||
@ -801,6 +816,11 @@ private func selectivePrivacySettingsControllerEntries(presentationData: Present
|
||||
settingInfoText = presentationData.strings.Privacy_Birthday_CustomHelp
|
||||
disableForText = presentationData.strings.PrivacyLastSeenSettings_NeverShareWith
|
||||
enableForText = presentationData.strings.PrivacyLastSeenSettings_AlwaysShareWith
|
||||
case .giftsAutoSave:
|
||||
settingTitle = presentationData.strings.Privacy_Gifts_WhoCanSeeMyBio
|
||||
settingInfoText = presentationData.strings.Privacy_Gifts_CustomHelp
|
||||
disableForText = presentationData.strings.Privacy_GroupsAndChannels_NeverAllow
|
||||
enableForText = presentationData.strings.Privacy_GroupsAndChannels_AlwaysAllow
|
||||
}
|
||||
|
||||
if case .forwards = kind {
|
||||
@ -857,12 +877,12 @@ private func selectivePrivacySettingsControllerEntries(presentationData: Present
|
||||
|
||||
switch state.setting {
|
||||
case .everybody:
|
||||
entries.append(.disableFor(presentationData.theme, disableForText, stringForUserCount(state.disableFor, enableForPremium: false, strings: presentationData.strings)))
|
||||
entries.append(.disableFor(presentationData.theme, disableForText, stringForUserCount(state.disableFor, enableForPremium: false, enableForBots: false, strings: presentationData.strings)))
|
||||
case .contacts:
|
||||
entries.append(.disableFor(presentationData.theme, disableForText, stringForUserCount(state.disableFor, enableForPremium: false, strings: presentationData.strings)))
|
||||
entries.append(.enableFor(presentationData.theme, enableForText, stringForUserCount(state.enableFor, enableForPremium: state.enableForPremium, strings: presentationData.strings)))
|
||||
entries.append(.disableFor(presentationData.theme, disableForText, stringForUserCount(state.disableFor, enableForPremium: false, enableForBots: false, strings: presentationData.strings)))
|
||||
entries.append(.enableFor(presentationData.theme, enableForText, stringForUserCount(state.enableFor, enableForPremium: state.enableForPremium, enableForBots: state.enableForBots, strings: presentationData.strings)))
|
||||
case .nobody:
|
||||
entries.append(.enableFor(presentationData.theme, enableForText, stringForUserCount(state.enableFor, enableForPremium: state.enableForPremium, strings: presentationData.strings)))
|
||||
entries.append(.enableFor(presentationData.theme, enableForText, stringForUserCount(state.enableFor, enableForPremium: state.enableForPremium, enableForBots: state.enableForBots, strings: presentationData.strings)))
|
||||
}
|
||||
let exceptionsInfo: String
|
||||
if case .profilePhoto = kind {
|
||||
@ -891,12 +911,12 @@ private func selectivePrivacySettingsControllerEntries(presentationData: Present
|
||||
if let callP2PMode = state.callP2PMode, let disableFor = state.callP2PDisableFor, let enableFor = state.callP2PEnableFor {
|
||||
switch callP2PMode {
|
||||
case .everybody:
|
||||
entries.append(.callsP2PDisableFor(presentationData.theme, disableForText, stringForUserCount(disableFor, enableForPremium: false, strings: presentationData.strings)))
|
||||
entries.append(.callsP2PDisableFor(presentationData.theme, disableForText, stringForUserCount(disableFor, enableForPremium: false, enableForBots: false, strings: presentationData.strings)))
|
||||
case .contacts:
|
||||
entries.append(.callsP2PDisableFor(presentationData.theme, disableForText, stringForUserCount(disableFor, enableForPremium: false, strings: presentationData.strings)))
|
||||
entries.append(.callsP2PEnableFor(presentationData.theme, enableForText, stringForUserCount(enableFor, enableForPremium: false, strings: presentationData.strings)))
|
||||
entries.append(.callsP2PDisableFor(presentationData.theme, disableForText, stringForUserCount(disableFor, enableForPremium: false, enableForBots: false, strings: presentationData.strings)))
|
||||
entries.append(.callsP2PEnableFor(presentationData.theme, enableForText, stringForUserCount(enableFor, enableForPremium: false, enableForBots: false, strings: presentationData.strings)))
|
||||
case .nobody:
|
||||
entries.append(.callsP2PEnableFor(presentationData.theme, enableForText, stringForUserCount(enableFor, enableForPremium: false, strings: presentationData.strings)))
|
||||
entries.append(.callsP2PEnableFor(presentationData.theme, enableForText, stringForUserCount(enableFor, enableForPremium: false, enableForBots: false, strings: presentationData.strings)))
|
||||
}
|
||||
}
|
||||
entries.append(.callsP2PPeersInfo(presentationData.theme, presentationData.strings.PrivacyLastSeenSettings_CustomShareSettingsHelp))
|
||||
@ -986,15 +1006,18 @@ public func selectivePrivacySettingsController(
|
||||
var initialEnableForPremium = false
|
||||
var initialDisableFor: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
||||
var initialEnableForCloseFriends = false
|
||||
var initialEnableForBots = false
|
||||
switch current {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremiumValue):
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremiumValue, enableForBots):
|
||||
initialEnableFor = enableFor
|
||||
initialEnableForCloseFriends = enableForCloseFriends
|
||||
initialEnableForPremium = enableForPremiumValue
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremiumValue):
|
||||
initialEnableForBots = enableForBots
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremiumValue, enableForBots):
|
||||
initialEnableFor = enableFor
|
||||
initialDisableFor = disableFor
|
||||
initialEnableForPremium = enableForPremiumValue
|
||||
initialEnableForBots = enableForBots
|
||||
case let .enableEveryone(disableFor):
|
||||
initialDisableFor = disableFor
|
||||
}
|
||||
@ -1003,11 +1026,11 @@ public func selectivePrivacySettingsController(
|
||||
var initialCallEnableForCloseFriends = false
|
||||
if let callCurrent = callSettings?.0 {
|
||||
switch callCurrent {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, _):
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, _, _):
|
||||
initialCallP2PEnableFor = enableFor
|
||||
initialCallP2PDisableFor = [:]
|
||||
initialCallEnableForCloseFriends = enableForCloseFriends
|
||||
case let .enableContacts(enableFor, disableFor, _):
|
||||
case let .enableContacts(enableFor, disableFor, _, _):
|
||||
initialCallP2PEnableFor = enableFor
|
||||
initialCallP2PDisableFor = disableFor
|
||||
case let .enableEveryone(disableFor):
|
||||
@ -1016,7 +1039,7 @@ public func selectivePrivacySettingsController(
|
||||
}
|
||||
}
|
||||
|
||||
let initialState = SelectivePrivacySettingsControllerState(setting: SelectivePrivacySettingType(current), enableFor: initialEnableFor, enableForPremium: initialEnableForPremium, disableFor: initialDisableFor, enableForCloseFriends: initialEnableForCloseFriends, saving: false, callDataSaving: callSettings?.1.dataSaving, callP2PMode: callSettings != nil ? SelectivePrivacySettingType(callSettings!.0) : nil, callP2PEnableFor: initialCallP2PEnableFor, callP2PDisableFor: initialCallP2PDisableFor, callP2PEnableForCloseFriends: initialCallEnableForCloseFriends, callIntegrationAvailable: callIntegrationAvailable, callIntegrationEnabled: callSettings?.1.enableSystemIntegration, phoneDiscoveryEnabled: phoneDiscoveryEnabled, hideReadTimeEnabled: globalSettings?.hideReadTime, uploadedPhoto: nil)
|
||||
let initialState = SelectivePrivacySettingsControllerState(setting: SelectivePrivacySettingType(current), enableFor: initialEnableFor, enableForPremium: initialEnableForPremium, disableFor: initialDisableFor, enableForCloseFriends: initialEnableForCloseFriends, enableForBots: initialEnableForBots, saving: false, callDataSaving: callSettings?.1.dataSaving, callP2PMode: callSettings != nil ? SelectivePrivacySettingType(callSettings!.0) : nil, callP2PEnableFor: initialCallP2PEnableFor, callP2PDisableFor: initialCallP2PDisableFor, callP2PEnableForCloseFriends: initialCallEnableForCloseFriends, callIntegrationAvailable: callIntegrationAvailable, callIntegrationEnabled: callSettings?.1.enableSystemIntegration, phoneDiscoveryEnabled: phoneDiscoveryEnabled, hideReadTimeEnabled: globalSettings?.hideReadTime, uploadedPhoto: nil)
|
||||
|
||||
let statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
||||
let stateValue = Atomic(value: initialState)
|
||||
@ -1059,6 +1082,8 @@ public func selectivePrivacySettingsController(
|
||||
title = strings.Privacy_Bio_AlwaysShareWith_Title
|
||||
case .birthday:
|
||||
title = strings.Privacy_Birthday_AlwaysShareWith_Title
|
||||
case .giftsAutoSave:
|
||||
title = strings.Privacy_Gifts_AlwaysAllow_Title
|
||||
}
|
||||
} else {
|
||||
switch kind {
|
||||
@ -1080,6 +1105,8 @@ public func selectivePrivacySettingsController(
|
||||
title = strings.Privacy_Bio_NeverShareWith_Title
|
||||
case .birthday:
|
||||
title = strings.Privacy_Birthday_NeverShareWith_Title
|
||||
case .giftsAutoSave:
|
||||
title = strings.Privacy_Gifts_NeverAllow_Title
|
||||
}
|
||||
}
|
||||
var peerIds: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
||||
@ -1105,15 +1132,19 @@ public func selectivePrivacySettingsController(
|
||||
}
|
||||
return state
|
||||
}
|
||||
if peerIds.isEmpty && !stateValue.with({ $0 }).enableForPremium {
|
||||
if peerIds.isEmpty && !stateValue.with({ $0 }).enableForPremium && !stateValue.with({ $0 }).enableForBots {
|
||||
enum AdditionalCategoryId: Int {
|
||||
case premiumUsers
|
||||
case bots
|
||||
}
|
||||
|
||||
var displayPremiumCategory = false
|
||||
var displayBotsCategory = false
|
||||
switch kind {
|
||||
case .groupInvitations:
|
||||
displayPremiumCategory = true
|
||||
case .giftsAutoSave:
|
||||
displayBotsCategory = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -1134,6 +1165,18 @@ public func selectivePrivacySettingsController(
|
||||
selectedCategories.insert(AdditionalCategoryId.premiumUsers.rawValue)
|
||||
}
|
||||
|
||||
if displayBotsCategory && enable {
|
||||
additionalCategories = [
|
||||
ChatListNodeAdditionalCategory(
|
||||
id: AdditionalCategoryId.bots.rawValue,
|
||||
icon: generateAvatarImage(size: CGSize(width: 40.0, height: 40.0), icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/Filters/Bot"), color: .white), cornerRadius: 12.0, color: .violet),
|
||||
smallIcon: generateAvatarImage(size: CGSize(width: 22.0, height: 22.0), icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/Filters/Bot"), color: .white), iconScale: 0.6, cornerRadius: 6.0, circleCorners: true, color: .violet),
|
||||
title: strings.PrivacySettings_CategoryBots,
|
||||
appearance: .option(sectionTitle: strings.PrivacySettings_SearchUserTypesHeader)
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
let controller = context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: context, mode: .chatSelection(ContactMultiselectionControllerMode.ChatSelection(
|
||||
title: strings.PrivacySettings_SearchUsersTitle,
|
||||
searchPlaceholder: strings.PrivacySettings_SearchUsersPlaceholder,
|
||||
@ -1149,12 +1192,14 @@ public func selectivePrivacySettingsController(
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] result in
|
||||
var peerIds: [ContactListPeerId] = []
|
||||
var premiumSelected = false
|
||||
var botsSelected = false
|
||||
if case let .result(peerIdsValue, additionalOptionIds) = result {
|
||||
peerIds = peerIdsValue
|
||||
premiumSelected = additionalOptionIds.contains(AdditionalCategoryId.premiumUsers.rawValue)
|
||||
botsSelected = additionalOptionIds.contains(AdditionalCategoryId.bots.rawValue)
|
||||
}
|
||||
|
||||
if peerIds.isEmpty && !premiumSelected {
|
||||
if peerIds.isEmpty && !premiumSelected && !botsSelected {
|
||||
controller?.dismiss()
|
||||
return
|
||||
}
|
||||
@ -1204,7 +1249,7 @@ public func selectivePrivacySettingsController(
|
||||
disableFor.removeValue(forKey: key)
|
||||
}
|
||||
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor)
|
||||
.withUpdatedEnableForPremium(premiumSelected ? true : state.enableForPremium)
|
||||
.withUpdatedEnableForPremium(premiumSelected ? true : state.enableForPremium).withUpdatedEnableForBots(botsSelected ? true : state.enableForBots)
|
||||
case .callP2P:
|
||||
var callP2PDisableFor = state.callP2PDisableFor ?? [:]
|
||||
for (key, _) in updatedPeerIds {
|
||||
@ -1234,16 +1279,21 @@ public func selectivePrivacySettingsController(
|
||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
} else {
|
||||
var displayPremiumCategory = false
|
||||
var displayBotsCategory = false
|
||||
switch kind {
|
||||
case .groupInvitations:
|
||||
if enable {
|
||||
displayPremiumCategory = true
|
||||
}
|
||||
case .giftsAutoSave:
|
||||
if enable {
|
||||
displayBotsCategory = true
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
let controller = selectivePrivacyPeersController(context: context, title: title, initialPeers: peerIds, initialEnableForPremium: displayPremiumCategory && stateValue.with({ $0 }).enableForPremium, displayPremiumCategory: displayPremiumCategory, updated: { updatedPeerIds, enableForPremium in
|
||||
let controller = selectivePrivacyPeersController(context: context, title: title, initialPeers: peerIds, initialEnableForPremium: displayPremiumCategory && stateValue.with({ $0 }).enableForPremium, displayPremiumCategory: displayPremiumCategory, initialEnableForBots: displayBotsCategory && stateValue.with({ $0 }).enableForBots, displayBotsCategory: displayBotsCategory, updated: { updatedPeerIds, enableForPremium, enableForBots in
|
||||
updateState { state in
|
||||
if enable {
|
||||
switch target {
|
||||
@ -1252,7 +1302,7 @@ public func selectivePrivacySettingsController(
|
||||
for (key, _) in updatedPeerIds {
|
||||
disableFor.removeValue(forKey: key)
|
||||
}
|
||||
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor).withUpdatedEnableForPremium(enableForPremium)
|
||||
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor).withUpdatedEnableForPremium(enableForPremium).withUpdatedEnableForBots(enableForBots)
|
||||
case .callP2P:
|
||||
var callP2PDisableFor = state.callP2PDisableFor ?? [:]
|
||||
for (key, _) in updatedPeerIds {
|
||||
@ -1393,6 +1443,8 @@ public func selectivePrivacySettingsController(
|
||||
title = presentationData.strings.Privacy_Bio
|
||||
case .birthday:
|
||||
title = presentationData.strings.Privacy_Birthday
|
||||
case .giftsAutoSave:
|
||||
title = presentationData.strings.Privacy_Gifts
|
||||
}
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(title), leftNavigationButton: nil, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: selectivePrivacySettingsControllerEntries(presentationData: presentationData, kind: kind, state: state, peerName: peerName ?? "", phoneNumber: phoneNumber, peer: peer, birthday: birthday, publicPhoto: publicPhoto.knownValue), style: .blocks, animateChanges: true)
|
||||
@ -1430,9 +1482,9 @@ public func selectivePrivacySettingsController(
|
||||
case .everybody:
|
||||
settings = SelectivePrivacySettings.enableEveryone(disableFor: state.disableFor)
|
||||
case .contacts:
|
||||
settings = SelectivePrivacySettings.enableContacts(enableFor: state.enableFor, disableFor: state.disableFor, enableForPremium: state.enableForPremium)
|
||||
settings = SelectivePrivacySettings.enableContacts(enableFor: state.enableFor, disableFor: state.disableFor, enableForPremium: state.enableForPremium, enableForBots: state.enableForBots)
|
||||
case .nobody:
|
||||
settings = SelectivePrivacySettings.disableEveryone(enableFor: state.enableFor, enableForCloseFriends: state.enableForCloseFriends, enableForPremium: state.enableForPremium)
|
||||
settings = SelectivePrivacySettings.disableEveryone(enableFor: state.enableFor, enableForCloseFriends: state.enableForCloseFriends, enableForPremium: state.enableForPremium, enableForBots: state.enableForBots)
|
||||
}
|
||||
|
||||
if case .phoneNumber = kind, let value = state.phoneDiscoveryEnabled {
|
||||
@ -1448,9 +1500,9 @@ public func selectivePrivacySettingsController(
|
||||
case .everybody:
|
||||
callP2PSettings = SelectivePrivacySettings.enableEveryone(disableFor: disableFor)
|
||||
case .contacts:
|
||||
callP2PSettings = SelectivePrivacySettings.enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: false)
|
||||
callP2PSettings = SelectivePrivacySettings.enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: false, enableForBots: false)
|
||||
case .nobody:
|
||||
callP2PSettings = SelectivePrivacySettings.disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: false)
|
||||
callP2PSettings = SelectivePrivacySettings.disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: false, enableForBots: false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1484,6 +1536,8 @@ public func selectivePrivacySettingsController(
|
||||
type = .bio
|
||||
case .birthday:
|
||||
type = .birthday
|
||||
case .giftsAutoSave:
|
||||
type = .giftsAutoSave
|
||||
}
|
||||
|
||||
let updateSettingsSignal = context.engine.privacy.updateSelectiveAccountPrivacySettings(type: type, settings: settings)
|
||||
|
@ -10,6 +10,7 @@ import PresentationDataUtils
|
||||
import AccountContext
|
||||
import ItemListPeerItem
|
||||
import ItemListPeerActionItem
|
||||
import AvatarNode
|
||||
|
||||
private final class SelectivePrivacyPeersControllerArguments {
|
||||
let context: AccountContext
|
||||
@ -20,8 +21,9 @@ private final class SelectivePrivacyPeersControllerArguments {
|
||||
let openPeer: (EnginePeer) -> Void
|
||||
let deleteAll: () -> Void
|
||||
let removePremiumUsers: () -> Void
|
||||
let removeBots: () -> Void
|
||||
|
||||
init(context: AccountContext, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, removePeer: @escaping (EnginePeer.Id) -> Void, addPeer: @escaping () -> Void, openPeer: @escaping (EnginePeer) -> Void, deleteAll: @escaping () -> Void, removePremiumUsers: @escaping () -> Void) {
|
||||
init(context: AccountContext, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, removePeer: @escaping (EnginePeer.Id) -> Void, addPeer: @escaping () -> Void, openPeer: @escaping (EnginePeer) -> Void, deleteAll: @escaping () -> Void, removePremiumUsers: @escaping () -> Void, removeBots: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
||||
self.removePeer = removePeer
|
||||
@ -29,6 +31,7 @@ private final class SelectivePrivacyPeersControllerArguments {
|
||||
self.openPeer = openPeer
|
||||
self.deleteAll = deleteAll
|
||||
self.removePremiumUsers = removePremiumUsers
|
||||
self.removeBots = removeBots
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +44,7 @@ private enum SelectivePrivacyPeersEntryStableId: Hashable {
|
||||
case header
|
||||
case add
|
||||
case premiumUsers
|
||||
case bots
|
||||
case peer(EnginePeer.Id)
|
||||
case delete
|
||||
}
|
||||
@ -49,8 +53,13 @@ private let premiumAvatarIcon: UIImage? = {
|
||||
return generatePremiumCategoryIcon(size: CGSize(width: 31.0, height: 31.0), cornerRadius: 8.0)
|
||||
}()
|
||||
|
||||
private let botsIcon: UIImage? = {
|
||||
return generateAvatarImage(size: CGSize(width: 31.0, height: 31.0), icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/Filters/Bot"), color: .white), cornerRadius: 8.0, color: .violet)
|
||||
}()
|
||||
|
||||
private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
case premiumUsersItem(ItemListPeerItemEditing, Bool)
|
||||
case botsItem(ItemListPeerItemEditing, Bool)
|
||||
case peerItem(Int32, PresentationDateTimeFormat, PresentationPersonNameOrder, SelectivePrivacyPeer, ItemListPeerItemEditing, Bool)
|
||||
case addItem(String, Bool)
|
||||
case headerItem(String)
|
||||
@ -58,7 +67,7 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
|
||||
var section: ItemListSectionId {
|
||||
switch self {
|
||||
case .addItem, .premiumUsersItem, .peerItem, .headerItem:
|
||||
case .addItem, .premiumUsersItem, .botsItem, .peerItem, .headerItem:
|
||||
return SelectivePrivacyPeersSection.peers.rawValue
|
||||
case .deleteItem:
|
||||
return SelectivePrivacyPeersSection.delete.rawValue
|
||||
@ -69,6 +78,8 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
switch self {
|
||||
case .premiumUsersItem:
|
||||
return .premiumUsers
|
||||
case .botsItem:
|
||||
return .bots
|
||||
case let .peerItem(_, _, _, peer, _, _):
|
||||
return .peer(peer.peer.id)
|
||||
case .addItem:
|
||||
@ -88,6 +99,12 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .botsItem(editing, isEnabled):
|
||||
if case .botsItem(editing, isEnabled) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .peerItem(lhsIndex, lhsDateTimeFormat, lhsNameOrder, lhsPeer, lhsEditing, lhsEnabled):
|
||||
if case let .peerItem(rhsIndex, rhsDateTimeFormat, rhsNameOrder, rhsPeer, rhsEditing, rhsEnabled) = rhs {
|
||||
if lhsIndex != rhsIndex {
|
||||
@ -143,26 +160,33 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
return true
|
||||
case let .peerItem(rhsIndex, _, _, _, _, _):
|
||||
return index < rhsIndex
|
||||
case .addItem, .headerItem, .premiumUsersItem:
|
||||
case .addItem, .headerItem, .premiumUsersItem, .botsItem:
|
||||
return false
|
||||
}
|
||||
case .premiumUsersItem:
|
||||
switch rhs {
|
||||
case .peerItem, .deleteItem:
|
||||
case .peerItem, .deleteItem, .botsItem:
|
||||
return true
|
||||
case .premiumUsersItem, .addItem, .headerItem:
|
||||
return false
|
||||
}
|
||||
case .botsItem:
|
||||
switch rhs {
|
||||
case .peerItem, .deleteItem:
|
||||
return true
|
||||
case .botsItem, .premiumUsersItem, .addItem, .headerItem:
|
||||
return false
|
||||
}
|
||||
case .addItem:
|
||||
switch rhs {
|
||||
case .peerItem, .deleteItem, .premiumUsersItem:
|
||||
case .peerItem, .deleteItem, .botsItem, .premiumUsersItem:
|
||||
return true
|
||||
case .addItem, .headerItem:
|
||||
return false
|
||||
}
|
||||
case .headerItem:
|
||||
switch rhs {
|
||||
case .peerItem, .deleteItem, .premiumUsersItem, .addItem:
|
||||
case .peerItem, .deleteItem, .botsItem, .premiumUsersItem, .addItem:
|
||||
return true
|
||||
case .headerItem:
|
||||
return false
|
||||
@ -182,6 +206,15 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
}, removePeer: { peerId in
|
||||
arguments.removePremiumUsers()
|
||||
})
|
||||
case let .botsItem(editing, enabled):
|
||||
let peer: EnginePeer = .user(TelegramUser(
|
||||
id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(2)), accessHash: nil, firstName: presentationData.strings.PrivacySettings_CategoryBots, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil))
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer, customAvatarIcon: botsIcon, presence: nil, text: .none, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
}, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
}, removePeer: { peerId in
|
||||
arguments.removeBots()
|
||||
})
|
||||
case let .peerItem(_, dateTimeFormat, nameDisplayOrder, peer, editing, enabled):
|
||||
var text: ItemListPeerItemText = .none
|
||||
if let group = peer.peer as? TelegramGroup {
|
||||
@ -221,11 +254,13 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||
|
||||
private struct SelectivePrivacyPeersControllerState: Equatable {
|
||||
var enableForPremium: Bool
|
||||
var enableForBots: Bool
|
||||
var editing: Bool
|
||||
var peerIdWithRevealedOptions: EnginePeer.Id?
|
||||
|
||||
init(enableForPremium: Bool, editing: Bool, peerIdWithRevealedOptions: EnginePeer.Id?) {
|
||||
init(enableForPremium: Bool, enableForBots: Bool, editing: Bool, peerIdWithRevealedOptions: EnginePeer.Id?) {
|
||||
self.enableForPremium = enableForPremium
|
||||
self.enableForBots = enableForBots
|
||||
self.editing = editing
|
||||
self.peerIdWithRevealedOptions = peerIdWithRevealedOptions
|
||||
}
|
||||
@ -247,6 +282,10 @@ private func selectivePrivacyPeersControllerEntries(presentationData: Presentati
|
||||
entries.append(.premiumUsersItem(ItemListPeerItemEditing(editable: true, editing: state.editing, revealed: state.peerIdWithRevealedOptions?.id._internalGetInt64Value() == 1), true))
|
||||
}
|
||||
|
||||
if state.enableForBots {
|
||||
entries.append(.botsItem(ItemListPeerItemEditing(editable: true, editing: state.editing, revealed: state.peerIdWithRevealedOptions?.id._internalGetInt64Value() == 2), true))
|
||||
}
|
||||
|
||||
var index: Int32 = 0
|
||||
for peer in peers {
|
||||
entries.append(.peerItem(index, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, peer, ItemListPeerItemEditing(editable: true, editing: state.editing, revealed: peer.peer.id == state.peerIdWithRevealedOptions), true))
|
||||
@ -260,8 +299,8 @@ private func selectivePrivacyPeersControllerEntries(presentationData: Presentati
|
||||
return entries
|
||||
}
|
||||
|
||||
public func selectivePrivacyPeersController(context: AccountContext, title: String, initialPeers: [EnginePeer.Id: SelectivePrivacyPeer], initialEnableForPremium: Bool, displayPremiumCategory: Bool, updated: @escaping ([EnginePeer.Id: SelectivePrivacyPeer], Bool) -> Void) -> ViewController {
|
||||
let initialState = SelectivePrivacyPeersControllerState(enableForPremium: initialEnableForPremium, editing: false, peerIdWithRevealedOptions: nil)
|
||||
public func selectivePrivacyPeersController(context: AccountContext, title: String, initialPeers: [EnginePeer.Id: SelectivePrivacyPeer], initialEnableForPremium: Bool, displayPremiumCategory: Bool, initialEnableForBots: Bool, displayBotsCategory: Bool, updated: @escaping ([EnginePeer.Id: SelectivePrivacyPeer], Bool, Bool) -> Void) -> ViewController {
|
||||
let initialState = SelectivePrivacyPeersControllerState(enableForPremium: initialEnableForPremium, enableForBots: initialEnableForBots, editing: false, peerIdWithRevealedOptions: nil)
|
||||
let statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
||||
let stateValue = Atomic(value: initialState)
|
||||
let updateState: ((SelectivePrivacyPeersControllerState) -> SelectivePrivacyPeersControllerState) -> Void = { f in
|
||||
@ -311,7 +350,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
for peer in updatedPeers {
|
||||
updatedPeerDict[peer.peer.id] = peer
|
||||
}
|
||||
updated(updatedPeerDict, stateValue.with({ $0 }).enableForPremium)
|
||||
updated(updatedPeerDict, stateValue.with({ $0 }).enableForPremium, stateValue.with({ $0 }).enableForBots)
|
||||
|
||||
if updatedPeerDict.isEmpty {
|
||||
dismissImpl?()
|
||||
@ -324,6 +363,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
}, addPeer: {
|
||||
enum AdditionalCategoryId: Int {
|
||||
case premiumUsers
|
||||
case bots
|
||||
}
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
@ -341,6 +381,17 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
)
|
||||
]
|
||||
}
|
||||
if displayBotsCategory {
|
||||
additionalCategories = [
|
||||
ChatListNodeAdditionalCategory(
|
||||
id: AdditionalCategoryId.bots.rawValue,
|
||||
icon: generateAvatarImage(size: CGSize(width: 40.0, height: 40.0), icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/Filters/Bot"), color: .white), cornerRadius: 12.0, color: .violet),
|
||||
smallIcon: generateAvatarImage(size: CGSize(width: 22.0, height: 22.0), icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/Filters/Bot"), color: .white), iconScale: 0.6, cornerRadius: 6.0, circleCorners: true, color: .violet),
|
||||
title: presentationData.strings.PrivacySettings_CategoryBots,
|
||||
appearance: .option(sectionTitle: presentationData.strings.PrivacySettings_SearchUserTypesHeader)
|
||||
)
|
||||
]
|
||||
}
|
||||
var selectedCategories = Set<Int>()
|
||||
if stateValue.with({ $0 }).enableForPremium {
|
||||
selectedCategories.insert(AdditionalCategoryId.premiumUsers.rawValue)
|
||||
@ -361,9 +412,11 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] result in
|
||||
var peerIds: [ContactListPeerId] = []
|
||||
var premiumSelected = false
|
||||
var botsSelected = false
|
||||
if case let .result(peerIdsValue, additionalOptionIds) = result {
|
||||
peerIds = peerIdsValue
|
||||
premiumSelected = additionalOptionIds.contains(AdditionalCategoryId.premiumUsers.rawValue)
|
||||
botsSelected = additionalOptionIds.contains(AdditionalCategoryId.bots.rawValue)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
@ -412,11 +465,12 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
for peer in updatedPeers {
|
||||
updatedPeerDict[peer.peer.id] = peer
|
||||
}
|
||||
updated(updatedPeerDict, premiumSelected)
|
||||
updated(updatedPeerDict, premiumSelected, botsSelected)
|
||||
|
||||
updateState { state in
|
||||
var state = state
|
||||
state.enableForPremium = premiumSelected
|
||||
state.enableForBots = botsSelected
|
||||
return state
|
||||
}
|
||||
|
||||
@ -451,7 +505,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
}
|
||||
|
||||
peersPromise.set(.single([]))
|
||||
updated([:], false)
|
||||
updated([:], false, false)
|
||||
|
||||
dismissImpl?()
|
||||
|
||||
@ -483,9 +537,36 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
for peer in updatedPeers {
|
||||
updatedPeerDict[peer.peer.id] = peer
|
||||
}
|
||||
updated(updatedPeerDict, false)
|
||||
updated(updatedPeerDict, stateValue.with({ $0 }).enableForPremium, stateValue.with({ $0 }).enableForBots)
|
||||
|
||||
if updatedPeerDict.isEmpty && !stateValue.with({ $0 }).enableForPremium {
|
||||
if updatedPeerDict.isEmpty && !stateValue.with({ $0 }).enableForPremium && !stateValue.with({ $0 }).enableForBots {
|
||||
dismissImpl?()
|
||||
}
|
||||
|
||||
return .complete()
|
||||
}
|
||||
|
||||
removePeerDisposable.set(applyPeers.start())
|
||||
}, removeBots: {
|
||||
updateState { state in
|
||||
var state = state
|
||||
state.enableForBots = false
|
||||
return state
|
||||
}
|
||||
let applyPeers: Signal<Void, NoError> = peersPromise.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { peers -> Signal<Void, NoError> in
|
||||
let updatedPeers = peers
|
||||
peersPromise.set(.single(updatedPeers))
|
||||
|
||||
var updatedPeerDict: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
||||
for peer in updatedPeers {
|
||||
updatedPeerDict[peer.peer.id] = peer
|
||||
}
|
||||
updated(updatedPeerDict, stateValue.with({ $0 }).enableForPremium, stateValue.with({ $0 }).enableForBots)
|
||||
|
||||
if updatedPeerDict.isEmpty && !stateValue.with({ $0 }).enableForPremium && !stateValue.with({ $0 }).enableForBots {
|
||||
dismissImpl?()
|
||||
}
|
||||
|
||||
|
@ -597,6 +597,8 @@ private func privacySearchableItems(context: AccountContext, privacySettings: Ac
|
||||
current = info.bio
|
||||
case .birthday:
|
||||
current = info.birthday
|
||||
case .giftsAutoSave:
|
||||
current = info.giftsAutoSave
|
||||
}
|
||||
|
||||
present(.push, selectivePrivacySettingsController(context: context, kind: kind, current: current, callSettings: callSettings != nil ? (info.voiceCallsP2P, callSettings!.0) : nil, voipConfiguration: callSettings?.1, callIntegrationAvailable: CallKitIntegration.isAvailable, updated: { updated, updatedCallSettings, _, _ in
|
||||
|
@ -30,7 +30,7 @@ public func makeBioPrivacyController(context: AccountContext, settings: Promise<
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
settings.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: updated, birthday: value.birthday, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
settings.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: updated, birthday: value.birthday, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -54,7 +54,7 @@ public func makeBirthdayPrivacyController(context: AccountContext, settings: Pro
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
settings.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: updated, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
settings.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, voiceMessages: value.voiceMessages, bio: value.bio, birthday: updated, giftsAutoSave: value.giftsAutoSave, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|
@ -432,15 +432,18 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[55761658] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneNumber($0) }
|
||||
dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) }
|
||||
dict[1461304012] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyProfilePhoto($0) }
|
||||
dict[-512548031] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyStarGiftsAutoSave($0) }
|
||||
dict[1335282456] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyStatusTimestamp($0) }
|
||||
dict[-1360618136] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyVoiceMessages($0) }
|
||||
dict[407582158] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowAll($0) }
|
||||
dict[1515179237] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowBots($0) }
|
||||
dict[-2079962673] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowChatParticipants($0) }
|
||||
dict[793067081] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowCloseFriends($0) }
|
||||
dict[218751099] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowContacts($0) }
|
||||
dict[2009975281] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowPremium($0) }
|
||||
dict[320652927] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowUsers($0) }
|
||||
dict[-697604407] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowAll($0) }
|
||||
dict[-991594219] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowBots($0) }
|
||||
dict[-380694650] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowChatParticipants($0) }
|
||||
dict[195371015] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowContacts($0) }
|
||||
dict[-1877932953] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowUsers($0) }
|
||||
@ -761,15 +764,18 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-778378131] = { return Api.PrivacyKey.parse_privacyKeyPhoneNumber($0) }
|
||||
dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) }
|
||||
dict[-1777000467] = { return Api.PrivacyKey.parse_privacyKeyProfilePhoto($0) }
|
||||
dict[749010424] = { return Api.PrivacyKey.parse_privacyKeyStarGiftsAutoSave($0) }
|
||||
dict[-1137792208] = { return Api.PrivacyKey.parse_privacyKeyStatusTimestamp($0) }
|
||||
dict[110621716] = { return Api.PrivacyKey.parse_privacyKeyVoiceMessages($0) }
|
||||
dict[1698855810] = { return Api.PrivacyRule.parse_privacyValueAllowAll($0) }
|
||||
dict[558242653] = { return Api.PrivacyRule.parse_privacyValueAllowBots($0) }
|
||||
dict[1796427406] = { return Api.PrivacyRule.parse_privacyValueAllowChatParticipants($0) }
|
||||
dict[-135735141] = { return Api.PrivacyRule.parse_privacyValueAllowCloseFriends($0) }
|
||||
dict[-123988] = { return Api.PrivacyRule.parse_privacyValueAllowContacts($0) }
|
||||
dict[-320241333] = { return Api.PrivacyRule.parse_privacyValueAllowPremium($0) }
|
||||
dict[-1198497870] = { return Api.PrivacyRule.parse_privacyValueAllowUsers($0) }
|
||||
dict[-1955338397] = { return Api.PrivacyRule.parse_privacyValueDisallowAll($0) }
|
||||
dict[-156895185] = { return Api.PrivacyRule.parse_privacyValueDisallowBots($0) }
|
||||
dict[1103656293] = { return Api.PrivacyRule.parse_privacyValueDisallowChatParticipants($0) }
|
||||
dict[-125240806] = { return Api.PrivacyRule.parse_privacyValueDisallowContacts($0) }
|
||||
dict[-463335103] = { return Api.PrivacyRule.parse_privacyValueDisallowUsers($0) }
|
||||
|
@ -459,6 +459,7 @@ public extension Api {
|
||||
case inputPrivacyKeyPhoneNumber
|
||||
case inputPrivacyKeyPhoneP2P
|
||||
case inputPrivacyKeyProfilePhoto
|
||||
case inputPrivacyKeyStarGiftsAutoSave
|
||||
case inputPrivacyKeyStatusTimestamp
|
||||
case inputPrivacyKeyVoiceMessages
|
||||
|
||||
@ -517,6 +518,12 @@ public extension Api {
|
||||
buffer.appendInt32(1461304012)
|
||||
}
|
||||
|
||||
break
|
||||
case .inputPrivacyKeyStarGiftsAutoSave:
|
||||
if boxed {
|
||||
buffer.appendInt32(-512548031)
|
||||
}
|
||||
|
||||
break
|
||||
case .inputPrivacyKeyStatusTimestamp:
|
||||
if boxed {
|
||||
@ -553,6 +560,8 @@ public extension Api {
|
||||
return ("inputPrivacyKeyPhoneP2P", [])
|
||||
case .inputPrivacyKeyProfilePhoto:
|
||||
return ("inputPrivacyKeyProfilePhoto", [])
|
||||
case .inputPrivacyKeyStarGiftsAutoSave:
|
||||
return ("inputPrivacyKeyStarGiftsAutoSave", [])
|
||||
case .inputPrivacyKeyStatusTimestamp:
|
||||
return ("inputPrivacyKeyStatusTimestamp", [])
|
||||
case .inputPrivacyKeyVoiceMessages:
|
||||
@ -587,6 +596,9 @@ public extension Api {
|
||||
public static func parse_inputPrivacyKeyProfilePhoto(_ reader: BufferReader) -> InputPrivacyKey? {
|
||||
return Api.InputPrivacyKey.inputPrivacyKeyProfilePhoto
|
||||
}
|
||||
public static func parse_inputPrivacyKeyStarGiftsAutoSave(_ reader: BufferReader) -> InputPrivacyKey? {
|
||||
return Api.InputPrivacyKey.inputPrivacyKeyStarGiftsAutoSave
|
||||
}
|
||||
public static func parse_inputPrivacyKeyStatusTimestamp(_ reader: BufferReader) -> InputPrivacyKey? {
|
||||
return Api.InputPrivacyKey.inputPrivacyKeyStatusTimestamp
|
||||
}
|
||||
@ -599,12 +611,14 @@ public extension Api {
|
||||
public extension Api {
|
||||
enum InputPrivacyRule: TypeConstructorDescription {
|
||||
case inputPrivacyValueAllowAll
|
||||
case inputPrivacyValueAllowBots
|
||||
case inputPrivacyValueAllowChatParticipants(chats: [Int64])
|
||||
case inputPrivacyValueAllowCloseFriends
|
||||
case inputPrivacyValueAllowContacts
|
||||
case inputPrivacyValueAllowPremium
|
||||
case inputPrivacyValueAllowUsers(users: [Api.InputUser])
|
||||
case inputPrivacyValueDisallowAll
|
||||
case inputPrivacyValueDisallowBots
|
||||
case inputPrivacyValueDisallowChatParticipants(chats: [Int64])
|
||||
case inputPrivacyValueDisallowContacts
|
||||
case inputPrivacyValueDisallowUsers(users: [Api.InputUser])
|
||||
@ -616,6 +630,12 @@ public extension Api {
|
||||
buffer.appendInt32(407582158)
|
||||
}
|
||||
|
||||
break
|
||||
case .inputPrivacyValueAllowBots:
|
||||
if boxed {
|
||||
buffer.appendInt32(1515179237)
|
||||
}
|
||||
|
||||
break
|
||||
case .inputPrivacyValueAllowChatParticipants(let chats):
|
||||
if boxed {
|
||||
@ -660,6 +680,12 @@ public extension Api {
|
||||
buffer.appendInt32(-697604407)
|
||||
}
|
||||
|
||||
break
|
||||
case .inputPrivacyValueDisallowBots:
|
||||
if boxed {
|
||||
buffer.appendInt32(-991594219)
|
||||
}
|
||||
|
||||
break
|
||||
case .inputPrivacyValueDisallowChatParticipants(let chats):
|
||||
if boxed {
|
||||
@ -694,6 +720,8 @@ public extension Api {
|
||||
switch self {
|
||||
case .inputPrivacyValueAllowAll:
|
||||
return ("inputPrivacyValueAllowAll", [])
|
||||
case .inputPrivacyValueAllowBots:
|
||||
return ("inputPrivacyValueAllowBots", [])
|
||||
case .inputPrivacyValueAllowChatParticipants(let chats):
|
||||
return ("inputPrivacyValueAllowChatParticipants", [("chats", chats as Any)])
|
||||
case .inputPrivacyValueAllowCloseFriends:
|
||||
@ -706,6 +734,8 @@ public extension Api {
|
||||
return ("inputPrivacyValueAllowUsers", [("users", users as Any)])
|
||||
case .inputPrivacyValueDisallowAll:
|
||||
return ("inputPrivacyValueDisallowAll", [])
|
||||
case .inputPrivacyValueDisallowBots:
|
||||
return ("inputPrivacyValueDisallowBots", [])
|
||||
case .inputPrivacyValueDisallowChatParticipants(let chats):
|
||||
return ("inputPrivacyValueDisallowChatParticipants", [("chats", chats as Any)])
|
||||
case .inputPrivacyValueDisallowContacts:
|
||||
@ -718,6 +748,9 @@ public extension Api {
|
||||
public static func parse_inputPrivacyValueAllowAll(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||
return Api.InputPrivacyRule.inputPrivacyValueAllowAll
|
||||
}
|
||||
public static func parse_inputPrivacyValueAllowBots(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||
return Api.InputPrivacyRule.inputPrivacyValueAllowBots
|
||||
}
|
||||
public static func parse_inputPrivacyValueAllowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||
var _1: [Int64]?
|
||||
if let _ = reader.readInt32() {
|
||||
@ -756,6 +789,9 @@ public extension Api {
|
||||
public static func parse_inputPrivacyValueDisallowAll(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||
return Api.InputPrivacyRule.inputPrivacyValueDisallowAll
|
||||
}
|
||||
public static func parse_inputPrivacyValueDisallowBots(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||
return Api.InputPrivacyRule.inputPrivacyValueDisallowBots
|
||||
}
|
||||
public static func parse_inputPrivacyValueDisallowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||
var _1: [Int64]?
|
||||
if let _ = reader.readInt32() {
|
||||
|
@ -1105,6 +1105,7 @@ public extension Api {
|
||||
case privacyKeyPhoneNumber
|
||||
case privacyKeyPhoneP2P
|
||||
case privacyKeyProfilePhoto
|
||||
case privacyKeyStarGiftsAutoSave
|
||||
case privacyKeyStatusTimestamp
|
||||
case privacyKeyVoiceMessages
|
||||
|
||||
@ -1163,6 +1164,12 @@ public extension Api {
|
||||
buffer.appendInt32(-1777000467)
|
||||
}
|
||||
|
||||
break
|
||||
case .privacyKeyStarGiftsAutoSave:
|
||||
if boxed {
|
||||
buffer.appendInt32(749010424)
|
||||
}
|
||||
|
||||
break
|
||||
case .privacyKeyStatusTimestamp:
|
||||
if boxed {
|
||||
@ -1199,6 +1206,8 @@ public extension Api {
|
||||
return ("privacyKeyPhoneP2P", [])
|
||||
case .privacyKeyProfilePhoto:
|
||||
return ("privacyKeyProfilePhoto", [])
|
||||
case .privacyKeyStarGiftsAutoSave:
|
||||
return ("privacyKeyStarGiftsAutoSave", [])
|
||||
case .privacyKeyStatusTimestamp:
|
||||
return ("privacyKeyStatusTimestamp", [])
|
||||
case .privacyKeyVoiceMessages:
|
||||
@ -1233,6 +1242,9 @@ public extension Api {
|
||||
public static func parse_privacyKeyProfilePhoto(_ reader: BufferReader) -> PrivacyKey? {
|
||||
return Api.PrivacyKey.privacyKeyProfilePhoto
|
||||
}
|
||||
public static func parse_privacyKeyStarGiftsAutoSave(_ reader: BufferReader) -> PrivacyKey? {
|
||||
return Api.PrivacyKey.privacyKeyStarGiftsAutoSave
|
||||
}
|
||||
public static func parse_privacyKeyStatusTimestamp(_ reader: BufferReader) -> PrivacyKey? {
|
||||
return Api.PrivacyKey.privacyKeyStatusTimestamp
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
public extension Api {
|
||||
enum PrivacyRule: TypeConstructorDescription {
|
||||
case privacyValueAllowAll
|
||||
case privacyValueAllowBots
|
||||
case privacyValueAllowChatParticipants(chats: [Int64])
|
||||
case privacyValueAllowCloseFriends
|
||||
case privacyValueAllowContacts
|
||||
case privacyValueAllowPremium
|
||||
case privacyValueAllowUsers(users: [Int64])
|
||||
case privacyValueDisallowAll
|
||||
case privacyValueDisallowBots
|
||||
case privacyValueDisallowChatParticipants(chats: [Int64])
|
||||
case privacyValueDisallowContacts
|
||||
case privacyValueDisallowUsers(users: [Int64])
|
||||
@ -18,6 +20,12 @@ public extension Api {
|
||||
buffer.appendInt32(1698855810)
|
||||
}
|
||||
|
||||
break
|
||||
case .privacyValueAllowBots:
|
||||
if boxed {
|
||||
buffer.appendInt32(558242653)
|
||||
}
|
||||
|
||||
break
|
||||
case .privacyValueAllowChatParticipants(let chats):
|
||||
if boxed {
|
||||
@ -62,6 +70,12 @@ public extension Api {
|
||||
buffer.appendInt32(-1955338397)
|
||||
}
|
||||
|
||||
break
|
||||
case .privacyValueDisallowBots:
|
||||
if boxed {
|
||||
buffer.appendInt32(-156895185)
|
||||
}
|
||||
|
||||
break
|
||||
case .privacyValueDisallowChatParticipants(let chats):
|
||||
if boxed {
|
||||
@ -96,6 +110,8 @@ public extension Api {
|
||||
switch self {
|
||||
case .privacyValueAllowAll:
|
||||
return ("privacyValueAllowAll", [])
|
||||
case .privacyValueAllowBots:
|
||||
return ("privacyValueAllowBots", [])
|
||||
case .privacyValueAllowChatParticipants(let chats):
|
||||
return ("privacyValueAllowChatParticipants", [("chats", chats as Any)])
|
||||
case .privacyValueAllowCloseFriends:
|
||||
@ -108,6 +124,8 @@ public extension Api {
|
||||
return ("privacyValueAllowUsers", [("users", users as Any)])
|
||||
case .privacyValueDisallowAll:
|
||||
return ("privacyValueDisallowAll", [])
|
||||
case .privacyValueDisallowBots:
|
||||
return ("privacyValueDisallowBots", [])
|
||||
case .privacyValueDisallowChatParticipants(let chats):
|
||||
return ("privacyValueDisallowChatParticipants", [("chats", chats as Any)])
|
||||
case .privacyValueDisallowContacts:
|
||||
@ -120,6 +138,9 @@ public extension Api {
|
||||
public static func parse_privacyValueAllowAll(_ reader: BufferReader) -> PrivacyRule? {
|
||||
return Api.PrivacyRule.privacyValueAllowAll
|
||||
}
|
||||
public static func parse_privacyValueAllowBots(_ reader: BufferReader) -> PrivacyRule? {
|
||||
return Api.PrivacyRule.privacyValueAllowBots
|
||||
}
|
||||
public static func parse_privacyValueAllowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
|
||||
var _1: [Int64]?
|
||||
if let _ = reader.readInt32() {
|
||||
@ -158,6 +179,9 @@ public extension Api {
|
||||
public static func parse_privacyValueDisallowAll(_ reader: BufferReader) -> PrivacyRule? {
|
||||
return Api.PrivacyRule.privacyValueDisallowAll
|
||||
}
|
||||
public static func parse_privacyValueDisallowBots(_ reader: BufferReader) -> PrivacyRule? {
|
||||
return Api.PrivacyRule.privacyValueDisallowBots
|
||||
}
|
||||
public static func parse_privacyValueDisallowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
|
||||
var _1: [Int64]?
|
||||
if let _ = reader.readInt32() {
|
||||
|
@ -35,8 +35,8 @@ public final class SelectivePrivacyPeer: Equatable {
|
||||
|
||||
public enum SelectivePrivacySettings: Equatable {
|
||||
case enableEveryone(disableFor: [PeerId: SelectivePrivacyPeer])
|
||||
case enableContacts(enableFor: [PeerId: SelectivePrivacyPeer], disableFor: [PeerId: SelectivePrivacyPeer], enableForPremium: Bool)
|
||||
case disableEveryone(enableFor: [PeerId: SelectivePrivacyPeer], enableForCloseFriends: Bool, enableForPremium: Bool)
|
||||
case enableContacts(enableFor: [PeerId: SelectivePrivacyPeer], disableFor: [PeerId: SelectivePrivacyPeer], enableForPremium: Bool, enableForBots: Bool)
|
||||
case disableEveryone(enableFor: [PeerId: SelectivePrivacyPeer], enableForCloseFriends: Bool, enableForPremium: Bool, enableForBots: Bool)
|
||||
|
||||
public static func ==(lhs: SelectivePrivacySettings, rhs: SelectivePrivacySettings) -> Bool {
|
||||
switch lhs {
|
||||
@ -46,14 +46,14 @@ public enum SelectivePrivacySettings: Equatable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
||||
if case .enableContacts(enableFor, disableFor, enableForPremium) = rhs {
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||
if case .enableContacts(enableFor, disableFor, enableForPremium, enableForBots) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
||||
if case .disableEveryone(enableFor, enableForCloseFriends, enableForPremium) = rhs {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||
if case .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@ -63,10 +63,10 @@ public enum SelectivePrivacySettings: Equatable {
|
||||
|
||||
func withEnabledPeers(_ peers: [PeerId: SelectivePrivacyPeer]) -> SelectivePrivacySettings {
|
||||
switch self {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
||||
return .disableEveryone(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium)
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
||||
return .enableContacts(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), disableFor: disableFor, enableForPremium: enableForPremium)
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||
return .disableEveryone(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||
return .enableContacts(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), disableFor: disableFor, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||
case .enableEveryone:
|
||||
return self
|
||||
}
|
||||
@ -76,8 +76,8 @@ public enum SelectivePrivacySettings: Equatable {
|
||||
switch self {
|
||||
case .disableEveryone:
|
||||
return self
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForPremium: enableForPremium)
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||
case let .enableEveryone(disableFor):
|
||||
return .enableEveryone(disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }))
|
||||
}
|
||||
@ -85,10 +85,10 @@ public enum SelectivePrivacySettings: Equatable {
|
||||
|
||||
func withEnableForPremium(_ enableForPremium: Bool) -> SelectivePrivacySettings {
|
||||
switch self {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, _):
|
||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium)
|
||||
case let .enableContacts(enableFor, disableFor, _):
|
||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: enableForPremium)
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, _, enableForBots):
|
||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||
case let .enableContacts(enableFor, disableFor, _, enableForBots):
|
||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||
case .enableEveryone:
|
||||
return self
|
||||
}
|
||||
@ -96,14 +96,25 @@ public enum SelectivePrivacySettings: Equatable {
|
||||
|
||||
func withEnableForCloseFriends(_ enableForCloseFriends: Bool) -> SelectivePrivacySettings {
|
||||
switch self {
|
||||
case let .disableEveryone(enableFor, _, enableForPremium):
|
||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium)
|
||||
case let .disableEveryone(enableFor, _, enableForPremium, enableForBots):
|
||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||
case .enableContacts:
|
||||
return self
|
||||
case .enableEveryone:
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
func withEnableForBots(_ enableForBots: Bool?) -> SelectivePrivacySettings {
|
||||
switch self {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, _):
|
||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots == true)
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium, _):
|
||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: enableForPremium, enableForBots: enableForBots == true)
|
||||
case let .enableEveryone(disableFor):
|
||||
return .enableEveryone(disableFor: disableFor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct AccountPrivacySettings: Equatable {
|
||||
@ -118,12 +129,13 @@ public struct AccountPrivacySettings: Equatable {
|
||||
public var voiceMessages: SelectivePrivacySettings
|
||||
public var bio: SelectivePrivacySettings
|
||||
public var birthday: SelectivePrivacySettings
|
||||
public var giftsAutoSave: SelectivePrivacySettings
|
||||
|
||||
public var globalSettings: GlobalPrivacySettings
|
||||
public var accountRemovalTimeout: Int32
|
||||
public var messageAutoremoveTimeout: Int32?
|
||||
|
||||
public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, phoneNumber: SelectivePrivacySettings, phoneDiscoveryEnabled: Bool, voiceMessages: SelectivePrivacySettings, bio: SelectivePrivacySettings, birthday: SelectivePrivacySettings, globalSettings: GlobalPrivacySettings, accountRemovalTimeout: Int32, messageAutoremoveTimeout: Int32?) {
|
||||
public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, phoneNumber: SelectivePrivacySettings, phoneDiscoveryEnabled: Bool, voiceMessages: SelectivePrivacySettings, bio: SelectivePrivacySettings, birthday: SelectivePrivacySettings, giftsAutoSave: SelectivePrivacySettings, globalSettings: GlobalPrivacySettings, accountRemovalTimeout: Int32, messageAutoremoveTimeout: Int32?) {
|
||||
self.presence = presence
|
||||
self.groupInvitations = groupInvitations
|
||||
self.voiceCalls = voiceCalls
|
||||
@ -135,6 +147,7 @@ public struct AccountPrivacySettings: Equatable {
|
||||
self.voiceMessages = voiceMessages
|
||||
self.bio = bio
|
||||
self.birthday = birthday
|
||||
self.giftsAutoSave = giftsAutoSave
|
||||
self.globalSettings = globalSettings
|
||||
self.accountRemovalTimeout = accountRemovalTimeout
|
||||
self.messageAutoremoveTimeout = messageAutoremoveTimeout
|
||||
@ -174,6 +187,9 @@ public struct AccountPrivacySettings: Equatable {
|
||||
if lhs.birthday != rhs.birthday {
|
||||
return false
|
||||
}
|
||||
if lhs.giftsAutoSave != rhs.giftsAutoSave {
|
||||
return false
|
||||
}
|
||||
if lhs.globalSettings != rhs.globalSettings {
|
||||
return false
|
||||
}
|
||||
@ -190,19 +206,20 @@ public struct AccountPrivacySettings: Equatable {
|
||||
|
||||
extension SelectivePrivacySettings {
|
||||
init(apiRules: [Api.PrivacyRule], peers: [PeerId: SelectivePrivacyPeer]) {
|
||||
var current: SelectivePrivacySettings = .disableEveryone(enableFor: [:], enableForCloseFriends: false, enableForPremium: false)
|
||||
var current: SelectivePrivacySettings = .disableEveryone(enableFor: [:], enableForCloseFriends: false, enableForPremium: false, enableForBots: false)
|
||||
|
||||
var disableFor: [PeerId: SelectivePrivacyPeer] = [:]
|
||||
var enableFor: [PeerId: SelectivePrivacyPeer] = [:]
|
||||
var enableForCloseFriends: Bool = false
|
||||
var enableForPremium: Bool = false
|
||||
var enableForBots: Bool?
|
||||
|
||||
for rule in apiRules {
|
||||
switch rule {
|
||||
case .privacyValueAllowAll:
|
||||
current = .enableEveryone(disableFor: [:])
|
||||
case .privacyValueAllowContacts:
|
||||
current = .enableContacts(enableFor: [:], disableFor: [:], enableForPremium: false)
|
||||
current = .enableContacts(enableFor: [:], disableFor: [:], enableForPremium: false, enableForBots: false)
|
||||
case let .privacyValueAllowUsers(users):
|
||||
for id in users {
|
||||
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))] {
|
||||
@ -239,10 +256,14 @@ extension SelectivePrivacySettings {
|
||||
enableForCloseFriends = true
|
||||
case .privacyValueAllowPremium:
|
||||
enableForPremium = true
|
||||
case .privacyValueAllowBots:
|
||||
enableForBots = true
|
||||
case .privacyValueDisallowBots:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
self = current.withEnabledPeers(enableFor).withDisabledPeers(disableFor).withEnableForCloseFriends(enableForCloseFriends).withEnableForPremium(enableForPremium)
|
||||
self = current.withEnabledPeers(enableFor).withDisabledPeers(disableFor).withEnableForCloseFriends(enableForCloseFriends).withEnableForPremium(enableForPremium).withEnableForBots(enableForBots)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,15 +51,16 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
||||
let voiceMessagesPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyVoiceMessages))
|
||||
let bioPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyAbout))
|
||||
let birthdayPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyBirthday))
|
||||
let giftsAutoSavePrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyStarGiftsAutoSave))
|
||||
let autoremoveTimeout = account.network.request(Api.functions.account.getAccountTTL())
|
||||
let globalPrivacySettings = account.network.request(Api.functions.account.getGlobalPrivacySettings())
|
||||
let messageAutoremoveTimeout = account.network.request(Api.functions.messages.getDefaultHistoryTTL())
|
||||
|
||||
return combineLatest(lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, voiceMessagesPrivacy, bioPrivacy, birthdayPrivacy, autoremoveTimeout, globalPrivacySettings, messageAutoremoveTimeout)
|
||||
return combineLatest(lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, voiceMessagesPrivacy, bioPrivacy, birthdayPrivacy, giftsAutoSavePrivacy, autoremoveTimeout, globalPrivacySettings, messageAutoremoveTimeout)
|
||||
|> `catch` { _ in
|
||||
return .complete()
|
||||
}
|
||||
|> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, voiceMessagesPrivacy, bioPrivacy, birthdayPrivacy, autoremoveTimeout, globalPrivacySettings, messageAutoremoveTimeout -> Signal<AccountPrivacySettings, NoError> in
|
||||
|> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, voiceMessagesPrivacy, bioPrivacy, birthdayPrivacy, giftsAutoSavePrivacy, autoremoveTimeout, globalPrivacySettings, messageAutoremoveTimeout -> Signal<AccountPrivacySettings, NoError> in
|
||||
let accountTimeoutSeconds: Int32
|
||||
switch autoremoveTimeout {
|
||||
case let .accountDaysTTL(days):
|
||||
@ -86,6 +87,7 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
||||
let voiceMessagesRules: [Api.PrivacyRule]
|
||||
let bioRules: [Api.PrivacyRule]
|
||||
let birthdayRules: [Api.PrivacyRule]
|
||||
let giftsAutoSaveRules: [Api.PrivacyRule]
|
||||
var apiUsers: [Api.User] = []
|
||||
var apiChats: [Api.Chat] = []
|
||||
|
||||
@ -172,6 +174,13 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
||||
birthdayRules = rules
|
||||
}
|
||||
|
||||
switch giftsAutoSavePrivacy {
|
||||
case let .privacyRules(rules, chats, users):
|
||||
apiUsers.append(contentsOf: users)
|
||||
apiChats.append(contentsOf: chats)
|
||||
giftsAutoSaveRules = rules
|
||||
}
|
||||
|
||||
var peers: [SelectivePrivacyPeer] = []
|
||||
for user in apiUsers {
|
||||
peers.append(SelectivePrivacyPeer(peer: TelegramUser(user: user), participantCount: nil))
|
||||
@ -237,6 +246,7 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
||||
voiceMessages: SelectivePrivacySettings(apiRules: voiceMessagesRules, peers: peerMap),
|
||||
bio: SelectivePrivacySettings(apiRules: bioRules, peers: peerMap),
|
||||
birthday: SelectivePrivacySettings(apiRules: birthdayRules, peers: peerMap),
|
||||
giftsAutoSave: SelectivePrivacySettings(apiRules: giftsAutoSaveRules, peers: peerMap),
|
||||
globalSettings: globalSettings,
|
||||
accountRemovalTimeout: accountTimeoutSeconds,
|
||||
messageAutoremoveTimeout: messageAutoremoveSeconds
|
||||
@ -371,6 +381,7 @@ public enum UpdateSelectiveAccountPrivacySettingsType {
|
||||
case voiceMessages
|
||||
case bio
|
||||
case birthday
|
||||
case giftsAutoSave
|
||||
|
||||
var apiKey: Api.InputPrivacyKey {
|
||||
switch self {
|
||||
@ -394,6 +405,8 @@ public enum UpdateSelectiveAccountPrivacySettingsType {
|
||||
return .inputPrivacyKeyAbout
|
||||
case .birthday:
|
||||
return .inputPrivacyKeyBirthday
|
||||
case .giftsAutoSave:
|
||||
return .inputPrivacyKeyStarGiftsAutoSave
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -425,7 +438,7 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
var rules: [Api.InputPrivacyRule] = []
|
||||
switch settings {
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||
let enablePeers = apiUserAndGroupIds(peerIds: enableFor)
|
||||
|
||||
if !enablePeers.users.isEmpty {
|
||||
@ -442,7 +455,10 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd
|
||||
if enableForPremium {
|
||||
rules.append(.inputPrivacyValueAllowPremium)
|
||||
}
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
||||
if enableForBots {
|
||||
rules.append(.inputPrivacyValueAllowBots)
|
||||
}
|
||||
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||
let enablePeers = apiUserAndGroupIds(peerIds: enableFor)
|
||||
let disablePeers = apiUserAndGroupIds(peerIds: disableFor)
|
||||
|
||||
@ -464,7 +480,9 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd
|
||||
if enableForPremium {
|
||||
rules.append(.inputPrivacyValueAllowPremium)
|
||||
}
|
||||
let _ = enableForPremium
|
||||
if enableForBots {
|
||||
rules.append(.inputPrivacyValueAllowBots)
|
||||
}
|
||||
case let .enableEveryone(disableFor):
|
||||
let disablePeers = apiUserAndGroupIds(peerIds: disableFor)
|
||||
|
||||
|
@ -2458,7 +2458,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
let presence = current.presence
|
||||
var disabledFor: [PeerId: SelectivePrivacyPeer] = [:]
|
||||
switch presence {
|
||||
case let .enableEveryone(disabledForValue), let .enableContacts(_, disabledForValue, _):
|
||||
case let .enableEveryone(disabledForValue), let .enableContacts(_, disabledForValue, _, _):
|
||||
disabledFor = disabledForValue
|
||||
default:
|
||||
break
|
||||
|
@ -249,12 +249,24 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
let placeholder: Signal<(FileMediaReference, Bool)?, NoError>
|
||||
if let botAppSettings = controller.botAppSettings {
|
||||
Queue.mainQueue().justDispatch {
|
||||
if let backgroundColor = botAppSettings.backgroundColor {
|
||||
let backgroundColor: Int32?
|
||||
let headerColor: Int32?
|
||||
if let backgroundDarkColor = botAppSettings.backgroundDarkColor, self.presentationData.theme.overallDarkAppearance {
|
||||
backgroundColor = backgroundDarkColor
|
||||
} else {
|
||||
backgroundColor = botAppSettings.backgroundColor
|
||||
}
|
||||
if let headerDarkColor = botAppSettings.headerDarkColor, self.presentationData.theme.overallDarkAppearance {
|
||||
headerColor = headerDarkColor
|
||||
} else {
|
||||
headerColor = botAppSettings.headerColor
|
||||
}
|
||||
if let backgroundColor {
|
||||
self.appBackgroundColor = UIColor(rgb: UInt32(bitPattern: backgroundColor))
|
||||
self.placeholderBackgroundColor = self.appBackgroundColor
|
||||
self.updateBackgroundColor(transition: .immediate)
|
||||
}
|
||||
if let headerColor = botAppSettings.headerColor {
|
||||
if let headerColor {
|
||||
self.headerColor = UIColor(rgb: UInt32(bitPattern: headerColor))
|
||||
self.updateHeaderBackgroundColor(transition: .immediate)
|
||||
}
|
||||
@ -2131,14 +2143,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
if let refreshRate {
|
||||
self.motionManager.accelerometerUpdateInterval = refreshRate * 0.001
|
||||
}
|
||||
self.motionManager.startAccelerometerUpdates(to: OperationQueue.main) { data, error in
|
||||
if let data = data {
|
||||
let gravityConstant = 9.81
|
||||
self.webView?.sendEvent(
|
||||
name: "accelerometer_changed",
|
||||
data: "{x: \(data.acceleration.x * gravityConstant), y: \(data.acceleration.y * gravityConstant), z: \(data.acceleration.z * gravityConstant)}"
|
||||
)
|
||||
self.motionManager.startAccelerometerUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||
guard let self, let data else {
|
||||
return
|
||||
}
|
||||
let gravityConstant = 9.81
|
||||
self.webView?.sendEvent(
|
||||
name: "accelerometer_changed",
|
||||
data: "{x: \(data.acceleration.x * gravityConstant), y: \(data.acceleration.y * gravityConstant), z: \(data.acceleration.z * gravityConstant)}"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if self.motionManager.isAccelerometerActive {
|
||||
@ -2164,13 +2177,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
if let refreshRate {
|
||||
self.motionManager.deviceMotionUpdateInterval = refreshRate * 0.001
|
||||
}
|
||||
self.motionManager.startDeviceMotionUpdates(to: OperationQueue.main) { data, error in
|
||||
if let data {
|
||||
self.webView?.sendEvent(
|
||||
name: "device_orientation_changed",
|
||||
data: "{alpha: \(data.attitude.roll), beta: \(data.attitude.pitch), gamma: \(data.attitude.yaw)}"
|
||||
)
|
||||
self.motionManager.startDeviceMotionUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||
guard let self, let data else {
|
||||
return
|
||||
}
|
||||
self.webView?.sendEvent(
|
||||
name: "device_orientation_changed",
|
||||
data: "{alpha: \(data.attitude.roll), beta: \(data.attitude.pitch), gamma: \(data.attitude.yaw)}"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if self.motionManager.isDeviceMotionActive {
|
||||
@ -2196,13 +2210,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
if let refreshRate {
|
||||
self.motionManager.gyroUpdateInterval = refreshRate * 0.001
|
||||
}
|
||||
self.motionManager.startGyroUpdates(to: OperationQueue.main) { data, error in
|
||||
if let data {
|
||||
self.webView?.sendEvent(
|
||||
name: "gyroscope_changed",
|
||||
data: "{x: \(data.rotationRate.x), y: \(data.rotationRate.y), z: \(data.rotationRate.z)}"
|
||||
)
|
||||
self.motionManager.startGyroUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||
guard let self, let data else {
|
||||
return
|
||||
}
|
||||
self.webView?.sendEvent(
|
||||
name: "gyroscope_changed",
|
||||
data: "{x: \(data.rotationRate.x), y: \(data.rotationRate.y), z: \(data.rotationRate.z)}"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if self.motionManager.isGyroActive {
|
||||
|
Loading…
x
Reference in New Issue
Block a user