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" = "Display this gift on your page.";
|
||||||
"Notification.StarGift.Bot.Subtitle.Displaying" = "You are displaying 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 voiceMessages
|
||||||
case bio
|
case bio
|
||||||
case birthday
|
case birthday
|
||||||
|
case giftsAutoSave
|
||||||
}
|
}
|
||||||
|
@ -223,8 +223,12 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
|||||||
|
|
||||||
func safeInsets(inLandscape: Bool) -> UIEdgeInsets {
|
func safeInsets(inLandscape: Bool) -> UIEdgeInsets {
|
||||||
switch self {
|
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)
|
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:
|
default:
|
||||||
return UIEdgeInsets.zero
|
return UIEdgeInsets.zero
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,9 @@ private final class PrivacyAndSecurityControllerArguments {
|
|||||||
let openDataSettings: () -> Void
|
let openDataSettings: () -> Void
|
||||||
let openEmailSettings: (String?) -> Void
|
let openEmailSettings: (String?) -> Void
|
||||||
let openMessagePrivacy: () -> 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.account = account
|
||||||
self.openBlockedUsers = openBlockedUsers
|
self.openBlockedUsers = openBlockedUsers
|
||||||
self.openLastSeenPrivacy = openLastSeenPrivacy
|
self.openLastSeenPrivacy = openLastSeenPrivacy
|
||||||
@ -63,6 +64,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
|||||||
self.openDataSettings = openDataSettings
|
self.openDataSettings = openDataSettings
|
||||||
self.openEmailSettings = openEmailSettings
|
self.openEmailSettings = openEmailSettings
|
||||||
self.openMessagePrivacy = openMessagePrivacy
|
self.openMessagePrivacy = openMessagePrivacy
|
||||||
|
self.openGiftsPrivacy = openGiftsPrivacy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +106,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
|||||||
case messagePrivacy(PresentationTheme, Bool, Bool)
|
case messagePrivacy(PresentationTheme, Bool, Bool)
|
||||||
case bioPrivacy(PresentationTheme, String, String)
|
case bioPrivacy(PresentationTheme, String, String)
|
||||||
case birthdayPrivacy(PresentationTheme, String, String)
|
case birthdayPrivacy(PresentationTheme, String, String)
|
||||||
|
case giftsAutoSavePrivacy(PresentationTheme, String, String)
|
||||||
case selectivePrivacyInfo(PresentationTheme, String)
|
case selectivePrivacyInfo(PresentationTheme, String)
|
||||||
case passcode(PresentationTheme, String, Bool, String)
|
case passcode(PresentationTheme, String, Bool, String)
|
||||||
case twoStepVerification(PresentationTheme, String, String, TwoStepVerificationAccessConfiguration?)
|
case twoStepVerification(PresentationTheme, String, String, TwoStepVerificationAccessConfiguration?)
|
||||||
@ -127,7 +130,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
|||||||
return PrivacyAndSecuritySection.general.rawValue
|
return PrivacyAndSecuritySection.general.rawValue
|
||||||
case .loginEmail, .loginEmailInfo:
|
case .loginEmail, .loginEmailInfo:
|
||||||
return PrivacyAndSecuritySection.loginEmail.rawValue
|
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
|
return PrivacyAndSecuritySection.privacy.rawValue
|
||||||
case .autoArchiveHeader, .autoArchive, .autoArchiveInfo:
|
case .autoArchiveHeader, .autoArchive, .autoArchiveInfo:
|
||||||
return PrivacyAndSecuritySection.autoArchive.rawValue
|
return PrivacyAndSecuritySection.autoArchive.rawValue
|
||||||
@ -168,10 +171,12 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
|||||||
return 13
|
return 13
|
||||||
case .birthdayPrivacy:
|
case .birthdayPrivacy:
|
||||||
return 14
|
return 14
|
||||||
case .forwardPrivacy:
|
case .giftsAutoSavePrivacy:
|
||||||
return 15
|
return 15
|
||||||
case .voiceCallPrivacy:
|
case .forwardPrivacy:
|
||||||
return 16
|
return 16
|
||||||
|
case .voiceCallPrivacy:
|
||||||
|
return 17
|
||||||
case .voiceMessagePrivacy:
|
case .voiceMessagePrivacy:
|
||||||
return 18
|
return 18
|
||||||
case .messagePrivacy:
|
case .messagePrivacy:
|
||||||
@ -281,6 +286,12 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
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):
|
case let .selectivePrivacyInfo(lhsTheme, lhsText):
|
||||||
if case let .selectivePrivacyInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
if case let .selectivePrivacyInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||||
return true
|
return true
|
||||||
@ -431,6 +442,10 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
|||||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||||
arguments.openBirthdayPrivacy()
|
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):
|
case let .selectivePrivacyInfo(_, text):
|
||||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||||
case let .voiceCallPrivacy(_, text, value):
|
case let .voiceCallPrivacy(_, text, value):
|
||||||
@ -504,8 +519,8 @@ private func countForSelectivePeers(_ peers: [PeerId: SelectivePrivacyPeer]) ->
|
|||||||
|
|
||||||
private func stringForSelectiveSettings(strings: PresentationStrings, settings: SelectivePrivacySettings) -> String {
|
private func stringForSelectiveSettings(strings: PresentationStrings, settings: SelectivePrivacySettings) -> String {
|
||||||
switch settings {
|
switch settings {
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||||
if enableFor.isEmpty && !enableForCloseFriends && !enableForPremium {
|
if enableFor.isEmpty && !enableForCloseFriends && !enableForPremium && !enableForBots {
|
||||||
return strings.PrivacySettings_LastSeenNobody
|
return strings.PrivacySettings_LastSeenNobody
|
||||||
} else {
|
} else {
|
||||||
if enableForCloseFriends && enableForPremium {
|
if enableForCloseFriends && enableForPremium {
|
||||||
@ -520,6 +535,12 @@ private func stringForSelectiveSettings(strings: PresentationStrings, settings:
|
|||||||
} else {
|
} else {
|
||||||
return strings.PrivacySettings_ValuePremiumPlus("\(countForSelectivePeers(enableFor))").string
|
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 {
|
} else if enableForCloseFriends {
|
||||||
if enableFor.isEmpty {
|
if enableFor.isEmpty {
|
||||||
return strings.PrivacySettings_LastSeenCloseFriendsPlus("\(countForSelectivePeers(enableFor))").string
|
return strings.PrivacySettings_LastSeenCloseFriendsPlus("\(countForSelectivePeers(enableFor))").string
|
||||||
@ -540,9 +561,11 @@ private func stringForSelectiveSettings(strings: PresentationStrings, settings:
|
|||||||
} else {
|
} else {
|
||||||
return strings.PrivacySettings_LastSeenEverybodyMinus("\(countForSelectivePeers(disableFor))").string
|
return strings.PrivacySettings_LastSeenEverybodyMinus("\(countForSelectivePeers(disableFor))").string
|
||||||
}
|
}
|
||||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||||
if enableForPremium {
|
if enableForPremium {
|
||||||
return strings.PrivacySettings_ValuePremiumAndContacts
|
return strings.PrivacySettings_ValuePremiumAndContacts
|
||||||
|
} else if enableForBots {
|
||||||
|
return strings.PrivacySettings_ValueBots
|
||||||
} else {
|
} else {
|
||||||
if !enableFor.isEmpty && !disableFor.isEmpty {
|
if !enableFor.isEmpty && !disableFor.isEmpty {
|
||||||
return strings.PrivacySettings_LastSeenContactsMinusPlus("\(countForSelectivePeers(disableFor))", "\(countForSelectivePeers(enableFor))").string
|
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(.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(.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(.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(.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)))
|
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceCalls)))
|
||||||
if !isPremiumDisabled {
|
if !isPremiumDisabled {
|
||||||
@ -647,13 +671,14 @@ private func privacyAndSecurityControllerEntries(
|
|||||||
entries.append(.profilePhotoPrivacy(presentationData.theme, presentationData.strings.Privacy_ProfilePhoto, presentationData.strings.Channel_NotificationLoading))
|
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(.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(.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(.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(.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 {
|
if !isPremiumDisabled {
|
||||||
entries.append(.voiceMessagePrivacy(presentationData.theme, presentationData.strings.Privacy_VoiceMessages, presentationData.strings.Channel_NotificationLoading, isPremium))
|
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))
|
//entries.append(.selectivePrivacyInfo(presentationData.theme, presentationData.strings.PrivacyLastSeenSettings_GroupsAndChannelsHelp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +869,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -867,7 +892,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -904,7 +929,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -931,7 +956,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -954,7 +979,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -977,7 +1002,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1003,7 +1028,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1026,7 +1051,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1049,7 +1074,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1117,7 +1142,7 @@ public func privacyAndSecurityController(
|
|||||||
var globalSettings = value.globalSettings
|
var globalSettings = value.globalSettings
|
||||||
globalSettings.automaticallyArchiveAndMuteNonContacts = archiveValue
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1156,7 +1181,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1219,7 +1244,7 @@ public func privacyAndSecurityController(
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1269,7 +1294,7 @@ public func privacyAndSecurityController(
|
|||||||
var globalSettings = value.globalSettings
|
var globalSettings = value.globalSettings
|
||||||
globalSettings.nonContactChatsRequirePremium = settingValue
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -1286,6 +1311,29 @@ public func privacyAndSecurityController(
|
|||||||
}))
|
}))
|
||||||
}), true)
|
}), 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())
|
actionsDisposable.add(context.engine.peers.managedUpdatedRecentPeers().start())
|
||||||
|
@ -96,8 +96,8 @@ private enum SelectivePrivacySettingsSection: Int32 {
|
|||||||
case premium
|
case premium
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stringForUserCount(_ peers: [EnginePeer.Id: SelectivePrivacyPeer], enableForPremium: Bool, strings: PresentationStrings) -> String {
|
private func stringForUserCount(_ peers: [EnginePeer.Id: SelectivePrivacyPeer], enableForPremium: Bool, enableForBots: Bool, strings: PresentationStrings) -> String {
|
||||||
if peers.isEmpty && !enableForPremium {
|
if peers.isEmpty && !enableForPremium && !enableForBots {
|
||||||
return strings.PrivacyLastSeenSettings_EmpryUsersPlaceholder
|
return strings.PrivacyLastSeenSettings_EmpryUsersPlaceholder
|
||||||
} else {
|
} else {
|
||||||
var result = 0
|
var result = 0
|
||||||
@ -105,7 +105,13 @@ private func stringForUserCount(_ peers: [EnginePeer.Id: SelectivePrivacyPeer],
|
|||||||
result += peer.userCount
|
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 {
|
if result == 0 {
|
||||||
return strings.PrivacySettings_ValuePremium
|
return strings.PrivacySettings_ValuePremium
|
||||||
} else {
|
} else {
|
||||||
@ -588,6 +594,7 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
|||||||
let enableForPremium: Bool
|
let enableForPremium: Bool
|
||||||
let disableFor: [EnginePeer.Id: SelectivePrivacyPeer]
|
let disableFor: [EnginePeer.Id: SelectivePrivacyPeer]
|
||||||
let enableForCloseFriends: Bool
|
let enableForCloseFriends: Bool
|
||||||
|
let enableForBots: Bool
|
||||||
|
|
||||||
let saving: Bool
|
let saving: Bool
|
||||||
|
|
||||||
@ -603,12 +610,13 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
|||||||
|
|
||||||
let uploadedPhoto: UIImage?
|
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.setting = setting
|
||||||
self.enableFor = enableFor
|
self.enableFor = enableFor
|
||||||
self.enableForPremium = enableForPremium
|
self.enableForPremium = enableForPremium
|
||||||
self.disableFor = disableFor
|
self.disableFor = disableFor
|
||||||
self.enableForCloseFriends = enableForCloseFriends
|
self.enableForCloseFriends = enableForCloseFriends
|
||||||
|
self.enableForBots = enableForBots
|
||||||
self.saving = saving
|
self.saving = saving
|
||||||
self.callDataSaving = callDataSaving
|
self.callDataSaving = callDataSaving
|
||||||
self.callP2PMode = callP2PMode
|
self.callP2PMode = callP2PMode
|
||||||
@ -638,6 +646,9 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
|||||||
if lhs.enableForCloseFriends != rhs.enableForCloseFriends {
|
if lhs.enableForCloseFriends != rhs.enableForCloseFriends {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.enableForBots != rhs.enableForBots {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.saving != rhs.saving {
|
if lhs.saving != rhs.saving {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -676,59 +687,63 @@ private struct SelectivePrivacySettingsControllerState: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedSetting(_ setting: SelectivePrivacySettingType) -> SelectivePrivacySettingsControllerState {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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
|
settingInfoText = presentationData.strings.Privacy_Birthday_CustomHelp
|
||||||
disableForText = presentationData.strings.PrivacyLastSeenSettings_NeverShareWith
|
disableForText = presentationData.strings.PrivacyLastSeenSettings_NeverShareWith
|
||||||
enableForText = presentationData.strings.PrivacyLastSeenSettings_AlwaysShareWith
|
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 {
|
if case .forwards = kind {
|
||||||
@ -857,12 +877,12 @@ private func selectivePrivacySettingsControllerEntries(presentationData: Present
|
|||||||
|
|
||||||
switch state.setting {
|
switch state.setting {
|
||||||
case .everybody:
|
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:
|
case .contacts:
|
||||||
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)))
|
||||||
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)))
|
||||||
case .nobody:
|
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
|
let exceptionsInfo: String
|
||||||
if case .profilePhoto = kind {
|
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 {
|
if let callP2PMode = state.callP2PMode, let disableFor = state.callP2PDisableFor, let enableFor = state.callP2PEnableFor {
|
||||||
switch callP2PMode {
|
switch callP2PMode {
|
||||||
case .everybody:
|
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:
|
case .contacts:
|
||||||
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)))
|
||||||
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)))
|
||||||
case .nobody:
|
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))
|
entries.append(.callsP2PPeersInfo(presentationData.theme, presentationData.strings.PrivacyLastSeenSettings_CustomShareSettingsHelp))
|
||||||
@ -986,15 +1006,18 @@ public func selectivePrivacySettingsController(
|
|||||||
var initialEnableForPremium = false
|
var initialEnableForPremium = false
|
||||||
var initialDisableFor: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
var initialDisableFor: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
||||||
var initialEnableForCloseFriends = false
|
var initialEnableForCloseFriends = false
|
||||||
|
var initialEnableForBots = false
|
||||||
switch current {
|
switch current {
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremiumValue):
|
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremiumValue, enableForBots):
|
||||||
initialEnableFor = enableFor
|
initialEnableFor = enableFor
|
||||||
initialEnableForCloseFriends = enableForCloseFriends
|
initialEnableForCloseFriends = enableForCloseFriends
|
||||||
initialEnableForPremium = enableForPremiumValue
|
initialEnableForPremium = enableForPremiumValue
|
||||||
case let .enableContacts(enableFor, disableFor, enableForPremiumValue):
|
initialEnableForBots = enableForBots
|
||||||
|
case let .enableContacts(enableFor, disableFor, enableForPremiumValue, enableForBots):
|
||||||
initialEnableFor = enableFor
|
initialEnableFor = enableFor
|
||||||
initialDisableFor = disableFor
|
initialDisableFor = disableFor
|
||||||
initialEnableForPremium = enableForPremiumValue
|
initialEnableForPremium = enableForPremiumValue
|
||||||
|
initialEnableForBots = enableForBots
|
||||||
case let .enableEveryone(disableFor):
|
case let .enableEveryone(disableFor):
|
||||||
initialDisableFor = disableFor
|
initialDisableFor = disableFor
|
||||||
}
|
}
|
||||||
@ -1003,11 +1026,11 @@ public func selectivePrivacySettingsController(
|
|||||||
var initialCallEnableForCloseFriends = false
|
var initialCallEnableForCloseFriends = false
|
||||||
if let callCurrent = callSettings?.0 {
|
if let callCurrent = callSettings?.0 {
|
||||||
switch callCurrent {
|
switch callCurrent {
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, _):
|
case let .disableEveryone(enableFor, enableForCloseFriends, _, _):
|
||||||
initialCallP2PEnableFor = enableFor
|
initialCallP2PEnableFor = enableFor
|
||||||
initialCallP2PDisableFor = [:]
|
initialCallP2PDisableFor = [:]
|
||||||
initialCallEnableForCloseFriends = enableForCloseFriends
|
initialCallEnableForCloseFriends = enableForCloseFriends
|
||||||
case let .enableContacts(enableFor, disableFor, _):
|
case let .enableContacts(enableFor, disableFor, _, _):
|
||||||
initialCallP2PEnableFor = enableFor
|
initialCallP2PEnableFor = enableFor
|
||||||
initialCallP2PDisableFor = disableFor
|
initialCallP2PDisableFor = disableFor
|
||||||
case let .enableEveryone(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 statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
||||||
let stateValue = Atomic(value: initialState)
|
let stateValue = Atomic(value: initialState)
|
||||||
@ -1059,6 +1082,8 @@ public func selectivePrivacySettingsController(
|
|||||||
title = strings.Privacy_Bio_AlwaysShareWith_Title
|
title = strings.Privacy_Bio_AlwaysShareWith_Title
|
||||||
case .birthday:
|
case .birthday:
|
||||||
title = strings.Privacy_Birthday_AlwaysShareWith_Title
|
title = strings.Privacy_Birthday_AlwaysShareWith_Title
|
||||||
|
case .giftsAutoSave:
|
||||||
|
title = strings.Privacy_Gifts_AlwaysAllow_Title
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch kind {
|
switch kind {
|
||||||
@ -1080,6 +1105,8 @@ public func selectivePrivacySettingsController(
|
|||||||
title = strings.Privacy_Bio_NeverShareWith_Title
|
title = strings.Privacy_Bio_NeverShareWith_Title
|
||||||
case .birthday:
|
case .birthday:
|
||||||
title = strings.Privacy_Birthday_NeverShareWith_Title
|
title = strings.Privacy_Birthday_NeverShareWith_Title
|
||||||
|
case .giftsAutoSave:
|
||||||
|
title = strings.Privacy_Gifts_NeverAllow_Title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var peerIds: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
var peerIds: [EnginePeer.Id: SelectivePrivacyPeer] = [:]
|
||||||
@ -1105,15 +1132,19 @@ public func selectivePrivacySettingsController(
|
|||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
if peerIds.isEmpty && !stateValue.with({ $0 }).enableForPremium {
|
if peerIds.isEmpty && !stateValue.with({ $0 }).enableForPremium && !stateValue.with({ $0 }).enableForBots {
|
||||||
enum AdditionalCategoryId: Int {
|
enum AdditionalCategoryId: Int {
|
||||||
case premiumUsers
|
case premiumUsers
|
||||||
|
case bots
|
||||||
}
|
}
|
||||||
|
|
||||||
var displayPremiumCategory = false
|
var displayPremiumCategory = false
|
||||||
|
var displayBotsCategory = false
|
||||||
switch kind {
|
switch kind {
|
||||||
case .groupInvitations:
|
case .groupInvitations:
|
||||||
displayPremiumCategory = true
|
displayPremiumCategory = true
|
||||||
|
case .giftsAutoSave:
|
||||||
|
displayBotsCategory = true
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1134,6 +1165,18 @@ public func selectivePrivacySettingsController(
|
|||||||
selectedCategories.insert(AdditionalCategoryId.premiumUsers.rawValue)
|
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(
|
let controller = context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: context, mode: .chatSelection(ContactMultiselectionControllerMode.ChatSelection(
|
||||||
title: strings.PrivacySettings_SearchUsersTitle,
|
title: strings.PrivacySettings_SearchUsersTitle,
|
||||||
searchPlaceholder: strings.PrivacySettings_SearchUsersPlaceholder,
|
searchPlaceholder: strings.PrivacySettings_SearchUsersPlaceholder,
|
||||||
@ -1149,12 +1192,14 @@ public func selectivePrivacySettingsController(
|
|||||||
|> deliverOnMainQueue).start(next: { [weak controller] result in
|
|> deliverOnMainQueue).start(next: { [weak controller] result in
|
||||||
var peerIds: [ContactListPeerId] = []
|
var peerIds: [ContactListPeerId] = []
|
||||||
var premiumSelected = false
|
var premiumSelected = false
|
||||||
|
var botsSelected = false
|
||||||
if case let .result(peerIdsValue, additionalOptionIds) = result {
|
if case let .result(peerIdsValue, additionalOptionIds) = result {
|
||||||
peerIds = peerIdsValue
|
peerIds = peerIdsValue
|
||||||
premiumSelected = additionalOptionIds.contains(AdditionalCategoryId.premiumUsers.rawValue)
|
premiumSelected = additionalOptionIds.contains(AdditionalCategoryId.premiumUsers.rawValue)
|
||||||
|
botsSelected = additionalOptionIds.contains(AdditionalCategoryId.bots.rawValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if peerIds.isEmpty && !premiumSelected {
|
if peerIds.isEmpty && !premiumSelected && !botsSelected {
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1204,7 +1249,7 @@ public func selectivePrivacySettingsController(
|
|||||||
disableFor.removeValue(forKey: key)
|
disableFor.removeValue(forKey: key)
|
||||||
}
|
}
|
||||||
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor)
|
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor)
|
||||||
.withUpdatedEnableForPremium(premiumSelected ? true : state.enableForPremium)
|
.withUpdatedEnableForPremium(premiumSelected ? true : state.enableForPremium).withUpdatedEnableForBots(botsSelected ? true : state.enableForBots)
|
||||||
case .callP2P:
|
case .callP2P:
|
||||||
var callP2PDisableFor = state.callP2PDisableFor ?? [:]
|
var callP2PDisableFor = state.callP2PDisableFor ?? [:]
|
||||||
for (key, _) in updatedPeerIds {
|
for (key, _) in updatedPeerIds {
|
||||||
@ -1234,16 +1279,21 @@ public func selectivePrivacySettingsController(
|
|||||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||||
} else {
|
} else {
|
||||||
var displayPremiumCategory = false
|
var displayPremiumCategory = false
|
||||||
|
var displayBotsCategory = false
|
||||||
switch kind {
|
switch kind {
|
||||||
case .groupInvitations:
|
case .groupInvitations:
|
||||||
if enable {
|
if enable {
|
||||||
displayPremiumCategory = true
|
displayPremiumCategory = true
|
||||||
}
|
}
|
||||||
|
case .giftsAutoSave:
|
||||||
|
if enable {
|
||||||
|
displayBotsCategory = true
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break
|
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
|
updateState { state in
|
||||||
if enable {
|
if enable {
|
||||||
switch target {
|
switch target {
|
||||||
@ -1252,7 +1302,7 @@ public func selectivePrivacySettingsController(
|
|||||||
for (key, _) in updatedPeerIds {
|
for (key, _) in updatedPeerIds {
|
||||||
disableFor.removeValue(forKey: key)
|
disableFor.removeValue(forKey: key)
|
||||||
}
|
}
|
||||||
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor).withUpdatedEnableForPremium(enableForPremium)
|
return state.withUpdatedEnableFor(updatedPeerIds).withUpdatedDisableFor(disableFor).withUpdatedEnableForPremium(enableForPremium).withUpdatedEnableForBots(enableForBots)
|
||||||
case .callP2P:
|
case .callP2P:
|
||||||
var callP2PDisableFor = state.callP2PDisableFor ?? [:]
|
var callP2PDisableFor = state.callP2PDisableFor ?? [:]
|
||||||
for (key, _) in updatedPeerIds {
|
for (key, _) in updatedPeerIds {
|
||||||
@ -1393,6 +1443,8 @@ public func selectivePrivacySettingsController(
|
|||||||
title = presentationData.strings.Privacy_Bio
|
title = presentationData.strings.Privacy_Bio
|
||||||
case .birthday:
|
case .birthday:
|
||||||
title = presentationData.strings.Privacy_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 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)
|
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:
|
case .everybody:
|
||||||
settings = SelectivePrivacySettings.enableEveryone(disableFor: state.disableFor)
|
settings = SelectivePrivacySettings.enableEveryone(disableFor: state.disableFor)
|
||||||
case .contacts:
|
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:
|
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 {
|
if case .phoneNumber = kind, let value = state.phoneDiscoveryEnabled {
|
||||||
@ -1448,9 +1500,9 @@ public func selectivePrivacySettingsController(
|
|||||||
case .everybody:
|
case .everybody:
|
||||||
callP2PSettings = SelectivePrivacySettings.enableEveryone(disableFor: disableFor)
|
callP2PSettings = SelectivePrivacySettings.enableEveryone(disableFor: disableFor)
|
||||||
case .contacts:
|
case .contacts:
|
||||||
callP2PSettings = SelectivePrivacySettings.enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: false)
|
callP2PSettings = SelectivePrivacySettings.enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: false, enableForBots: false)
|
||||||
case .nobody:
|
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
|
type = .bio
|
||||||
case .birthday:
|
case .birthday:
|
||||||
type = .birthday
|
type = .birthday
|
||||||
|
case .giftsAutoSave:
|
||||||
|
type = .giftsAutoSave
|
||||||
}
|
}
|
||||||
|
|
||||||
let updateSettingsSignal = context.engine.privacy.updateSelectiveAccountPrivacySettings(type: type, settings: settings)
|
let updateSettingsSignal = context.engine.privacy.updateSelectiveAccountPrivacySettings(type: type, settings: settings)
|
||||||
|
@ -10,6 +10,7 @@ import PresentationDataUtils
|
|||||||
import AccountContext
|
import AccountContext
|
||||||
import ItemListPeerItem
|
import ItemListPeerItem
|
||||||
import ItemListPeerActionItem
|
import ItemListPeerActionItem
|
||||||
|
import AvatarNode
|
||||||
|
|
||||||
private final class SelectivePrivacyPeersControllerArguments {
|
private final class SelectivePrivacyPeersControllerArguments {
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
@ -20,8 +21,9 @@ private final class SelectivePrivacyPeersControllerArguments {
|
|||||||
let openPeer: (EnginePeer) -> Void
|
let openPeer: (EnginePeer) -> Void
|
||||||
let deleteAll: () -> Void
|
let deleteAll: () -> Void
|
||||||
let removePremiumUsers: () -> 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.context = context
|
||||||
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
||||||
self.removePeer = removePeer
|
self.removePeer = removePeer
|
||||||
@ -29,6 +31,7 @@ private final class SelectivePrivacyPeersControllerArguments {
|
|||||||
self.openPeer = openPeer
|
self.openPeer = openPeer
|
||||||
self.deleteAll = deleteAll
|
self.deleteAll = deleteAll
|
||||||
self.removePremiumUsers = removePremiumUsers
|
self.removePremiumUsers = removePremiumUsers
|
||||||
|
self.removeBots = removeBots
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +44,7 @@ private enum SelectivePrivacyPeersEntryStableId: Hashable {
|
|||||||
case header
|
case header
|
||||||
case add
|
case add
|
||||||
case premiumUsers
|
case premiumUsers
|
||||||
|
case bots
|
||||||
case peer(EnginePeer.Id)
|
case peer(EnginePeer.Id)
|
||||||
case delete
|
case delete
|
||||||
}
|
}
|
||||||
@ -49,8 +53,13 @@ private let premiumAvatarIcon: UIImage? = {
|
|||||||
return generatePremiumCategoryIcon(size: CGSize(width: 31.0, height: 31.0), cornerRadius: 8.0)
|
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 {
|
private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
||||||
case premiumUsersItem(ItemListPeerItemEditing, Bool)
|
case premiumUsersItem(ItemListPeerItemEditing, Bool)
|
||||||
|
case botsItem(ItemListPeerItemEditing, Bool)
|
||||||
case peerItem(Int32, PresentationDateTimeFormat, PresentationPersonNameOrder, SelectivePrivacyPeer, ItemListPeerItemEditing, Bool)
|
case peerItem(Int32, PresentationDateTimeFormat, PresentationPersonNameOrder, SelectivePrivacyPeer, ItemListPeerItemEditing, Bool)
|
||||||
case addItem(String, Bool)
|
case addItem(String, Bool)
|
||||||
case headerItem(String)
|
case headerItem(String)
|
||||||
@ -58,7 +67,7 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||||||
|
|
||||||
var section: ItemListSectionId {
|
var section: ItemListSectionId {
|
||||||
switch self {
|
switch self {
|
||||||
case .addItem, .premiumUsersItem, .peerItem, .headerItem:
|
case .addItem, .premiumUsersItem, .botsItem, .peerItem, .headerItem:
|
||||||
return SelectivePrivacyPeersSection.peers.rawValue
|
return SelectivePrivacyPeersSection.peers.rawValue
|
||||||
case .deleteItem:
|
case .deleteItem:
|
||||||
return SelectivePrivacyPeersSection.delete.rawValue
|
return SelectivePrivacyPeersSection.delete.rawValue
|
||||||
@ -69,6 +78,8 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||||||
switch self {
|
switch self {
|
||||||
case .premiumUsersItem:
|
case .premiumUsersItem:
|
||||||
return .premiumUsers
|
return .premiumUsers
|
||||||
|
case .botsItem:
|
||||||
|
return .bots
|
||||||
case let .peerItem(_, _, _, peer, _, _):
|
case let .peerItem(_, _, _, peer, _, _):
|
||||||
return .peer(peer.peer.id)
|
return .peer(peer.peer.id)
|
||||||
case .addItem:
|
case .addItem:
|
||||||
@ -88,6 +99,12 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
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):
|
case let .peerItem(lhsIndex, lhsDateTimeFormat, lhsNameOrder, lhsPeer, lhsEditing, lhsEnabled):
|
||||||
if case let .peerItem(rhsIndex, rhsDateTimeFormat, rhsNameOrder, rhsPeer, rhsEditing, rhsEnabled) = rhs {
|
if case let .peerItem(rhsIndex, rhsDateTimeFormat, rhsNameOrder, rhsPeer, rhsEditing, rhsEnabled) = rhs {
|
||||||
if lhsIndex != rhsIndex {
|
if lhsIndex != rhsIndex {
|
||||||
@ -143,26 +160,33 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||||||
return true
|
return true
|
||||||
case let .peerItem(rhsIndex, _, _, _, _, _):
|
case let .peerItem(rhsIndex, _, _, _, _, _):
|
||||||
return index < rhsIndex
|
return index < rhsIndex
|
||||||
case .addItem, .headerItem, .premiumUsersItem:
|
case .addItem, .headerItem, .premiumUsersItem, .botsItem:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case .premiumUsersItem:
|
case .premiumUsersItem:
|
||||||
switch rhs {
|
switch rhs {
|
||||||
case .peerItem, .deleteItem:
|
case .peerItem, .deleteItem, .botsItem:
|
||||||
return true
|
return true
|
||||||
case .premiumUsersItem, .addItem, .headerItem:
|
case .premiumUsersItem, .addItem, .headerItem:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
case .botsItem:
|
||||||
|
switch rhs {
|
||||||
|
case .peerItem, .deleteItem:
|
||||||
|
return true
|
||||||
|
case .botsItem, .premiumUsersItem, .addItem, .headerItem:
|
||||||
|
return false
|
||||||
|
}
|
||||||
case .addItem:
|
case .addItem:
|
||||||
switch rhs {
|
switch rhs {
|
||||||
case .peerItem, .deleteItem, .premiumUsersItem:
|
case .peerItem, .deleteItem, .botsItem, .premiumUsersItem:
|
||||||
return true
|
return true
|
||||||
case .addItem, .headerItem:
|
case .addItem, .headerItem:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case .headerItem:
|
case .headerItem:
|
||||||
switch rhs {
|
switch rhs {
|
||||||
case .peerItem, .deleteItem, .premiumUsersItem, .addItem:
|
case .peerItem, .deleteItem, .botsItem, .premiumUsersItem, .addItem:
|
||||||
return true
|
return true
|
||||||
case .headerItem:
|
case .headerItem:
|
||||||
return false
|
return false
|
||||||
@ -182,6 +206,15 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||||||
}, removePeer: { peerId in
|
}, removePeer: { peerId in
|
||||||
arguments.removePremiumUsers()
|
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):
|
case let .peerItem(_, dateTimeFormat, nameDisplayOrder, peer, editing, enabled):
|
||||||
var text: ItemListPeerItemText = .none
|
var text: ItemListPeerItemText = .none
|
||||||
if let group = peer.peer as? TelegramGroup {
|
if let group = peer.peer as? TelegramGroup {
|
||||||
@ -221,11 +254,13 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||||||
|
|
||||||
private struct SelectivePrivacyPeersControllerState: Equatable {
|
private struct SelectivePrivacyPeersControllerState: Equatable {
|
||||||
var enableForPremium: Bool
|
var enableForPremium: Bool
|
||||||
|
var enableForBots: Bool
|
||||||
var editing: Bool
|
var editing: Bool
|
||||||
var peerIdWithRevealedOptions: EnginePeer.Id?
|
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.enableForPremium = enableForPremium
|
||||||
|
self.enableForBots = enableForBots
|
||||||
self.editing = editing
|
self.editing = editing
|
||||||
self.peerIdWithRevealedOptions = peerIdWithRevealedOptions
|
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))
|
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
|
var index: Int32 = 0
|
||||||
for peer in peers {
|
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))
|
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
|
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 {
|
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, editing: false, peerIdWithRevealedOptions: nil)
|
let initialState = SelectivePrivacyPeersControllerState(enableForPremium: initialEnableForPremium, enableForBots: initialEnableForBots, editing: false, peerIdWithRevealedOptions: nil)
|
||||||
let statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
let statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
||||||
let stateValue = Atomic(value: initialState)
|
let stateValue = Atomic(value: initialState)
|
||||||
let updateState: ((SelectivePrivacyPeersControllerState) -> SelectivePrivacyPeersControllerState) -> Void = { f in
|
let updateState: ((SelectivePrivacyPeersControllerState) -> SelectivePrivacyPeersControllerState) -> Void = { f in
|
||||||
@ -311,7 +350,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
|||||||
for peer in updatedPeers {
|
for peer in updatedPeers {
|
||||||
updatedPeerDict[peer.peer.id] = peer
|
updatedPeerDict[peer.peer.id] = peer
|
||||||
}
|
}
|
||||||
updated(updatedPeerDict, stateValue.with({ $0 }).enableForPremium)
|
updated(updatedPeerDict, stateValue.with({ $0 }).enableForPremium, stateValue.with({ $0 }).enableForBots)
|
||||||
|
|
||||||
if updatedPeerDict.isEmpty {
|
if updatedPeerDict.isEmpty {
|
||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
@ -324,6 +363,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
|||||||
}, addPeer: {
|
}, addPeer: {
|
||||||
enum AdditionalCategoryId: Int {
|
enum AdditionalCategoryId: Int {
|
||||||
case premiumUsers
|
case premiumUsers
|
||||||
|
case bots
|
||||||
}
|
}
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
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>()
|
var selectedCategories = Set<Int>()
|
||||||
if stateValue.with({ $0 }).enableForPremium {
|
if stateValue.with({ $0 }).enableForPremium {
|
||||||
selectedCategories.insert(AdditionalCategoryId.premiumUsers.rawValue)
|
selectedCategories.insert(AdditionalCategoryId.premiumUsers.rawValue)
|
||||||
@ -361,9 +412,11 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
|||||||
|> deliverOnMainQueue).start(next: { [weak controller] result in
|
|> deliverOnMainQueue).start(next: { [weak controller] result in
|
||||||
var peerIds: [ContactListPeerId] = []
|
var peerIds: [ContactListPeerId] = []
|
||||||
var premiumSelected = false
|
var premiumSelected = false
|
||||||
|
var botsSelected = false
|
||||||
if case let .result(peerIdsValue, additionalOptionIds) = result {
|
if case let .result(peerIdsValue, additionalOptionIds) = result {
|
||||||
peerIds = peerIdsValue
|
peerIds = peerIdsValue
|
||||||
premiumSelected = additionalOptionIds.contains(AdditionalCategoryId.premiumUsers.rawValue)
|
premiumSelected = additionalOptionIds.contains(AdditionalCategoryId.premiumUsers.rawValue)
|
||||||
|
botsSelected = additionalOptionIds.contains(AdditionalCategoryId.bots.rawValue)
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -412,11 +465,12 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
|||||||
for peer in updatedPeers {
|
for peer in updatedPeers {
|
||||||
updatedPeerDict[peer.peer.id] = peer
|
updatedPeerDict[peer.peer.id] = peer
|
||||||
}
|
}
|
||||||
updated(updatedPeerDict, premiumSelected)
|
updated(updatedPeerDict, premiumSelected, botsSelected)
|
||||||
|
|
||||||
updateState { state in
|
updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
state.enableForPremium = premiumSelected
|
state.enableForPremium = premiumSelected
|
||||||
|
state.enableForBots = botsSelected
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +505,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
peersPromise.set(.single([]))
|
peersPromise.set(.single([]))
|
||||||
updated([:], false)
|
updated([:], false, false)
|
||||||
|
|
||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
|
|
||||||
@ -483,9 +537,36 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
|||||||
for peer in updatedPeers {
|
for peer in updatedPeers {
|
||||||
updatedPeerDict[peer.peer.id] = peer
|
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?()
|
dismissImpl?()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,6 +597,8 @@ private func privacySearchableItems(context: AccountContext, privacySettings: Ac
|
|||||||
current = info.bio
|
current = info.bio
|
||||||
case .birthday:
|
case .birthday:
|
||||||
current = info.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
|
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
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ public func makeBirthdayPrivacyController(context: AccountContext, settings: Pro
|
|||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||||
if let value = value {
|
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()
|
return .complete()
|
||||||
}
|
}
|
||||||
|
@ -432,15 +432,18 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[55761658] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneNumber($0) }
|
dict[55761658] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneNumber($0) }
|
||||||
dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) }
|
dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) }
|
||||||
dict[1461304012] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyProfilePhoto($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[1335282456] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyStatusTimestamp($0) }
|
||||||
dict[-1360618136] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyVoiceMessages($0) }
|
dict[-1360618136] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyVoiceMessages($0) }
|
||||||
dict[407582158] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowAll($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[-2079962673] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowChatParticipants($0) }
|
||||||
dict[793067081] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowCloseFriends($0) }
|
dict[793067081] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowCloseFriends($0) }
|
||||||
dict[218751099] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowContacts($0) }
|
dict[218751099] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowContacts($0) }
|
||||||
dict[2009975281] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowPremium($0) }
|
dict[2009975281] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowPremium($0) }
|
||||||
dict[320652927] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowUsers($0) }
|
dict[320652927] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowUsers($0) }
|
||||||
dict[-697604407] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowAll($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[-380694650] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowChatParticipants($0) }
|
||||||
dict[195371015] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowContacts($0) }
|
dict[195371015] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowContacts($0) }
|
||||||
dict[-1877932953] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowUsers($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[-778378131] = { return Api.PrivacyKey.parse_privacyKeyPhoneNumber($0) }
|
||||||
dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) }
|
dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) }
|
||||||
dict[-1777000467] = { return Api.PrivacyKey.parse_privacyKeyProfilePhoto($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[-1137792208] = { return Api.PrivacyKey.parse_privacyKeyStatusTimestamp($0) }
|
||||||
dict[110621716] = { return Api.PrivacyKey.parse_privacyKeyVoiceMessages($0) }
|
dict[110621716] = { return Api.PrivacyKey.parse_privacyKeyVoiceMessages($0) }
|
||||||
dict[1698855810] = { return Api.PrivacyRule.parse_privacyValueAllowAll($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[1796427406] = { return Api.PrivacyRule.parse_privacyValueAllowChatParticipants($0) }
|
||||||
dict[-135735141] = { return Api.PrivacyRule.parse_privacyValueAllowCloseFriends($0) }
|
dict[-135735141] = { return Api.PrivacyRule.parse_privacyValueAllowCloseFriends($0) }
|
||||||
dict[-123988] = { return Api.PrivacyRule.parse_privacyValueAllowContacts($0) }
|
dict[-123988] = { return Api.PrivacyRule.parse_privacyValueAllowContacts($0) }
|
||||||
dict[-320241333] = { return Api.PrivacyRule.parse_privacyValueAllowPremium($0) }
|
dict[-320241333] = { return Api.PrivacyRule.parse_privacyValueAllowPremium($0) }
|
||||||
dict[-1198497870] = { return Api.PrivacyRule.parse_privacyValueAllowUsers($0) }
|
dict[-1198497870] = { return Api.PrivacyRule.parse_privacyValueAllowUsers($0) }
|
||||||
dict[-1955338397] = { return Api.PrivacyRule.parse_privacyValueDisallowAll($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[1103656293] = { return Api.PrivacyRule.parse_privacyValueDisallowChatParticipants($0) }
|
||||||
dict[-125240806] = { return Api.PrivacyRule.parse_privacyValueDisallowContacts($0) }
|
dict[-125240806] = { return Api.PrivacyRule.parse_privacyValueDisallowContacts($0) }
|
||||||
dict[-463335103] = { return Api.PrivacyRule.parse_privacyValueDisallowUsers($0) }
|
dict[-463335103] = { return Api.PrivacyRule.parse_privacyValueDisallowUsers($0) }
|
||||||
|
@ -459,6 +459,7 @@ public extension Api {
|
|||||||
case inputPrivacyKeyPhoneNumber
|
case inputPrivacyKeyPhoneNumber
|
||||||
case inputPrivacyKeyPhoneP2P
|
case inputPrivacyKeyPhoneP2P
|
||||||
case inputPrivacyKeyProfilePhoto
|
case inputPrivacyKeyProfilePhoto
|
||||||
|
case inputPrivacyKeyStarGiftsAutoSave
|
||||||
case inputPrivacyKeyStatusTimestamp
|
case inputPrivacyKeyStatusTimestamp
|
||||||
case inputPrivacyKeyVoiceMessages
|
case inputPrivacyKeyVoiceMessages
|
||||||
|
|
||||||
@ -517,6 +518,12 @@ public extension Api {
|
|||||||
buffer.appendInt32(1461304012)
|
buffer.appendInt32(1461304012)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case .inputPrivacyKeyStarGiftsAutoSave:
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-512548031)
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case .inputPrivacyKeyStatusTimestamp:
|
case .inputPrivacyKeyStatusTimestamp:
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -553,6 +560,8 @@ public extension Api {
|
|||||||
return ("inputPrivacyKeyPhoneP2P", [])
|
return ("inputPrivacyKeyPhoneP2P", [])
|
||||||
case .inputPrivacyKeyProfilePhoto:
|
case .inputPrivacyKeyProfilePhoto:
|
||||||
return ("inputPrivacyKeyProfilePhoto", [])
|
return ("inputPrivacyKeyProfilePhoto", [])
|
||||||
|
case .inputPrivacyKeyStarGiftsAutoSave:
|
||||||
|
return ("inputPrivacyKeyStarGiftsAutoSave", [])
|
||||||
case .inputPrivacyKeyStatusTimestamp:
|
case .inputPrivacyKeyStatusTimestamp:
|
||||||
return ("inputPrivacyKeyStatusTimestamp", [])
|
return ("inputPrivacyKeyStatusTimestamp", [])
|
||||||
case .inputPrivacyKeyVoiceMessages:
|
case .inputPrivacyKeyVoiceMessages:
|
||||||
@ -587,6 +596,9 @@ public extension Api {
|
|||||||
public static func parse_inputPrivacyKeyProfilePhoto(_ reader: BufferReader) -> InputPrivacyKey? {
|
public static func parse_inputPrivacyKeyProfilePhoto(_ reader: BufferReader) -> InputPrivacyKey? {
|
||||||
return Api.InputPrivacyKey.inputPrivacyKeyProfilePhoto
|
return Api.InputPrivacyKey.inputPrivacyKeyProfilePhoto
|
||||||
}
|
}
|
||||||
|
public static func parse_inputPrivacyKeyStarGiftsAutoSave(_ reader: BufferReader) -> InputPrivacyKey? {
|
||||||
|
return Api.InputPrivacyKey.inputPrivacyKeyStarGiftsAutoSave
|
||||||
|
}
|
||||||
public static func parse_inputPrivacyKeyStatusTimestamp(_ reader: BufferReader) -> InputPrivacyKey? {
|
public static func parse_inputPrivacyKeyStatusTimestamp(_ reader: BufferReader) -> InputPrivacyKey? {
|
||||||
return Api.InputPrivacyKey.inputPrivacyKeyStatusTimestamp
|
return Api.InputPrivacyKey.inputPrivacyKeyStatusTimestamp
|
||||||
}
|
}
|
||||||
@ -599,12 +611,14 @@ public extension Api {
|
|||||||
public extension Api {
|
public extension Api {
|
||||||
enum InputPrivacyRule: TypeConstructorDescription {
|
enum InputPrivacyRule: TypeConstructorDescription {
|
||||||
case inputPrivacyValueAllowAll
|
case inputPrivacyValueAllowAll
|
||||||
|
case inputPrivacyValueAllowBots
|
||||||
case inputPrivacyValueAllowChatParticipants(chats: [Int64])
|
case inputPrivacyValueAllowChatParticipants(chats: [Int64])
|
||||||
case inputPrivacyValueAllowCloseFriends
|
case inputPrivacyValueAllowCloseFriends
|
||||||
case inputPrivacyValueAllowContacts
|
case inputPrivacyValueAllowContacts
|
||||||
case inputPrivacyValueAllowPremium
|
case inputPrivacyValueAllowPremium
|
||||||
case inputPrivacyValueAllowUsers(users: [Api.InputUser])
|
case inputPrivacyValueAllowUsers(users: [Api.InputUser])
|
||||||
case inputPrivacyValueDisallowAll
|
case inputPrivacyValueDisallowAll
|
||||||
|
case inputPrivacyValueDisallowBots
|
||||||
case inputPrivacyValueDisallowChatParticipants(chats: [Int64])
|
case inputPrivacyValueDisallowChatParticipants(chats: [Int64])
|
||||||
case inputPrivacyValueDisallowContacts
|
case inputPrivacyValueDisallowContacts
|
||||||
case inputPrivacyValueDisallowUsers(users: [Api.InputUser])
|
case inputPrivacyValueDisallowUsers(users: [Api.InputUser])
|
||||||
@ -616,6 +630,12 @@ public extension Api {
|
|||||||
buffer.appendInt32(407582158)
|
buffer.appendInt32(407582158)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case .inputPrivacyValueAllowBots:
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(1515179237)
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case .inputPrivacyValueAllowChatParticipants(let chats):
|
case .inputPrivacyValueAllowChatParticipants(let chats):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -660,6 +680,12 @@ public extension Api {
|
|||||||
buffer.appendInt32(-697604407)
|
buffer.appendInt32(-697604407)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case .inputPrivacyValueDisallowBots:
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-991594219)
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case .inputPrivacyValueDisallowChatParticipants(let chats):
|
case .inputPrivacyValueDisallowChatParticipants(let chats):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -694,6 +720,8 @@ public extension Api {
|
|||||||
switch self {
|
switch self {
|
||||||
case .inputPrivacyValueAllowAll:
|
case .inputPrivacyValueAllowAll:
|
||||||
return ("inputPrivacyValueAllowAll", [])
|
return ("inputPrivacyValueAllowAll", [])
|
||||||
|
case .inputPrivacyValueAllowBots:
|
||||||
|
return ("inputPrivacyValueAllowBots", [])
|
||||||
case .inputPrivacyValueAllowChatParticipants(let chats):
|
case .inputPrivacyValueAllowChatParticipants(let chats):
|
||||||
return ("inputPrivacyValueAllowChatParticipants", [("chats", chats as Any)])
|
return ("inputPrivacyValueAllowChatParticipants", [("chats", chats as Any)])
|
||||||
case .inputPrivacyValueAllowCloseFriends:
|
case .inputPrivacyValueAllowCloseFriends:
|
||||||
@ -706,6 +734,8 @@ public extension Api {
|
|||||||
return ("inputPrivacyValueAllowUsers", [("users", users as Any)])
|
return ("inputPrivacyValueAllowUsers", [("users", users as Any)])
|
||||||
case .inputPrivacyValueDisallowAll:
|
case .inputPrivacyValueDisallowAll:
|
||||||
return ("inputPrivacyValueDisallowAll", [])
|
return ("inputPrivacyValueDisallowAll", [])
|
||||||
|
case .inputPrivacyValueDisallowBots:
|
||||||
|
return ("inputPrivacyValueDisallowBots", [])
|
||||||
case .inputPrivacyValueDisallowChatParticipants(let chats):
|
case .inputPrivacyValueDisallowChatParticipants(let chats):
|
||||||
return ("inputPrivacyValueDisallowChatParticipants", [("chats", chats as Any)])
|
return ("inputPrivacyValueDisallowChatParticipants", [("chats", chats as Any)])
|
||||||
case .inputPrivacyValueDisallowContacts:
|
case .inputPrivacyValueDisallowContacts:
|
||||||
@ -718,6 +748,9 @@ public extension Api {
|
|||||||
public static func parse_inputPrivacyValueAllowAll(_ reader: BufferReader) -> InputPrivacyRule? {
|
public static func parse_inputPrivacyValueAllowAll(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||||
return Api.InputPrivacyRule.inputPrivacyValueAllowAll
|
return Api.InputPrivacyRule.inputPrivacyValueAllowAll
|
||||||
}
|
}
|
||||||
|
public static func parse_inputPrivacyValueAllowBots(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||||
|
return Api.InputPrivacyRule.inputPrivacyValueAllowBots
|
||||||
|
}
|
||||||
public static func parse_inputPrivacyValueAllowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? {
|
public static func parse_inputPrivacyValueAllowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||||
var _1: [Int64]?
|
var _1: [Int64]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
@ -756,6 +789,9 @@ public extension Api {
|
|||||||
public static func parse_inputPrivacyValueDisallowAll(_ reader: BufferReader) -> InputPrivacyRule? {
|
public static func parse_inputPrivacyValueDisallowAll(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||||
return Api.InputPrivacyRule.inputPrivacyValueDisallowAll
|
return Api.InputPrivacyRule.inputPrivacyValueDisallowAll
|
||||||
}
|
}
|
||||||
|
public static func parse_inputPrivacyValueDisallowBots(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||||
|
return Api.InputPrivacyRule.inputPrivacyValueDisallowBots
|
||||||
|
}
|
||||||
public static func parse_inputPrivacyValueDisallowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? {
|
public static func parse_inputPrivacyValueDisallowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? {
|
||||||
var _1: [Int64]?
|
var _1: [Int64]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
|
@ -1105,6 +1105,7 @@ public extension Api {
|
|||||||
case privacyKeyPhoneNumber
|
case privacyKeyPhoneNumber
|
||||||
case privacyKeyPhoneP2P
|
case privacyKeyPhoneP2P
|
||||||
case privacyKeyProfilePhoto
|
case privacyKeyProfilePhoto
|
||||||
|
case privacyKeyStarGiftsAutoSave
|
||||||
case privacyKeyStatusTimestamp
|
case privacyKeyStatusTimestamp
|
||||||
case privacyKeyVoiceMessages
|
case privacyKeyVoiceMessages
|
||||||
|
|
||||||
@ -1163,6 +1164,12 @@ public extension Api {
|
|||||||
buffer.appendInt32(-1777000467)
|
buffer.appendInt32(-1777000467)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case .privacyKeyStarGiftsAutoSave:
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(749010424)
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case .privacyKeyStatusTimestamp:
|
case .privacyKeyStatusTimestamp:
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -1199,6 +1206,8 @@ public extension Api {
|
|||||||
return ("privacyKeyPhoneP2P", [])
|
return ("privacyKeyPhoneP2P", [])
|
||||||
case .privacyKeyProfilePhoto:
|
case .privacyKeyProfilePhoto:
|
||||||
return ("privacyKeyProfilePhoto", [])
|
return ("privacyKeyProfilePhoto", [])
|
||||||
|
case .privacyKeyStarGiftsAutoSave:
|
||||||
|
return ("privacyKeyStarGiftsAutoSave", [])
|
||||||
case .privacyKeyStatusTimestamp:
|
case .privacyKeyStatusTimestamp:
|
||||||
return ("privacyKeyStatusTimestamp", [])
|
return ("privacyKeyStatusTimestamp", [])
|
||||||
case .privacyKeyVoiceMessages:
|
case .privacyKeyVoiceMessages:
|
||||||
@ -1233,6 +1242,9 @@ public extension Api {
|
|||||||
public static func parse_privacyKeyProfilePhoto(_ reader: BufferReader) -> PrivacyKey? {
|
public static func parse_privacyKeyProfilePhoto(_ reader: BufferReader) -> PrivacyKey? {
|
||||||
return Api.PrivacyKey.privacyKeyProfilePhoto
|
return Api.PrivacyKey.privacyKeyProfilePhoto
|
||||||
}
|
}
|
||||||
|
public static func parse_privacyKeyStarGiftsAutoSave(_ reader: BufferReader) -> PrivacyKey? {
|
||||||
|
return Api.PrivacyKey.privacyKeyStarGiftsAutoSave
|
||||||
|
}
|
||||||
public static func parse_privacyKeyStatusTimestamp(_ reader: BufferReader) -> PrivacyKey? {
|
public static func parse_privacyKeyStatusTimestamp(_ reader: BufferReader) -> PrivacyKey? {
|
||||||
return Api.PrivacyKey.privacyKeyStatusTimestamp
|
return Api.PrivacyKey.privacyKeyStatusTimestamp
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
public extension Api {
|
public extension Api {
|
||||||
enum PrivacyRule: TypeConstructorDescription {
|
enum PrivacyRule: TypeConstructorDescription {
|
||||||
case privacyValueAllowAll
|
case privacyValueAllowAll
|
||||||
|
case privacyValueAllowBots
|
||||||
case privacyValueAllowChatParticipants(chats: [Int64])
|
case privacyValueAllowChatParticipants(chats: [Int64])
|
||||||
case privacyValueAllowCloseFriends
|
case privacyValueAllowCloseFriends
|
||||||
case privacyValueAllowContacts
|
case privacyValueAllowContacts
|
||||||
case privacyValueAllowPremium
|
case privacyValueAllowPremium
|
||||||
case privacyValueAllowUsers(users: [Int64])
|
case privacyValueAllowUsers(users: [Int64])
|
||||||
case privacyValueDisallowAll
|
case privacyValueDisallowAll
|
||||||
|
case privacyValueDisallowBots
|
||||||
case privacyValueDisallowChatParticipants(chats: [Int64])
|
case privacyValueDisallowChatParticipants(chats: [Int64])
|
||||||
case privacyValueDisallowContacts
|
case privacyValueDisallowContacts
|
||||||
case privacyValueDisallowUsers(users: [Int64])
|
case privacyValueDisallowUsers(users: [Int64])
|
||||||
@ -18,6 +20,12 @@ public extension Api {
|
|||||||
buffer.appendInt32(1698855810)
|
buffer.appendInt32(1698855810)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case .privacyValueAllowBots:
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(558242653)
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case .privacyValueAllowChatParticipants(let chats):
|
case .privacyValueAllowChatParticipants(let chats):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -62,6 +70,12 @@ public extension Api {
|
|||||||
buffer.appendInt32(-1955338397)
|
buffer.appendInt32(-1955338397)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
case .privacyValueDisallowBots:
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-156895185)
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case .privacyValueDisallowChatParticipants(let chats):
|
case .privacyValueDisallowChatParticipants(let chats):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -96,6 +110,8 @@ public extension Api {
|
|||||||
switch self {
|
switch self {
|
||||||
case .privacyValueAllowAll:
|
case .privacyValueAllowAll:
|
||||||
return ("privacyValueAllowAll", [])
|
return ("privacyValueAllowAll", [])
|
||||||
|
case .privacyValueAllowBots:
|
||||||
|
return ("privacyValueAllowBots", [])
|
||||||
case .privacyValueAllowChatParticipants(let chats):
|
case .privacyValueAllowChatParticipants(let chats):
|
||||||
return ("privacyValueAllowChatParticipants", [("chats", chats as Any)])
|
return ("privacyValueAllowChatParticipants", [("chats", chats as Any)])
|
||||||
case .privacyValueAllowCloseFriends:
|
case .privacyValueAllowCloseFriends:
|
||||||
@ -108,6 +124,8 @@ public extension Api {
|
|||||||
return ("privacyValueAllowUsers", [("users", users as Any)])
|
return ("privacyValueAllowUsers", [("users", users as Any)])
|
||||||
case .privacyValueDisallowAll:
|
case .privacyValueDisallowAll:
|
||||||
return ("privacyValueDisallowAll", [])
|
return ("privacyValueDisallowAll", [])
|
||||||
|
case .privacyValueDisallowBots:
|
||||||
|
return ("privacyValueDisallowBots", [])
|
||||||
case .privacyValueDisallowChatParticipants(let chats):
|
case .privacyValueDisallowChatParticipants(let chats):
|
||||||
return ("privacyValueDisallowChatParticipants", [("chats", chats as Any)])
|
return ("privacyValueDisallowChatParticipants", [("chats", chats as Any)])
|
||||||
case .privacyValueDisallowContacts:
|
case .privacyValueDisallowContacts:
|
||||||
@ -120,6 +138,9 @@ public extension Api {
|
|||||||
public static func parse_privacyValueAllowAll(_ reader: BufferReader) -> PrivacyRule? {
|
public static func parse_privacyValueAllowAll(_ reader: BufferReader) -> PrivacyRule? {
|
||||||
return Api.PrivacyRule.privacyValueAllowAll
|
return Api.PrivacyRule.privacyValueAllowAll
|
||||||
}
|
}
|
||||||
|
public static func parse_privacyValueAllowBots(_ reader: BufferReader) -> PrivacyRule? {
|
||||||
|
return Api.PrivacyRule.privacyValueAllowBots
|
||||||
|
}
|
||||||
public static func parse_privacyValueAllowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
|
public static func parse_privacyValueAllowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
|
||||||
var _1: [Int64]?
|
var _1: [Int64]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
@ -158,6 +179,9 @@ public extension Api {
|
|||||||
public static func parse_privacyValueDisallowAll(_ reader: BufferReader) -> PrivacyRule? {
|
public static func parse_privacyValueDisallowAll(_ reader: BufferReader) -> PrivacyRule? {
|
||||||
return Api.PrivacyRule.privacyValueDisallowAll
|
return Api.PrivacyRule.privacyValueDisallowAll
|
||||||
}
|
}
|
||||||
|
public static func parse_privacyValueDisallowBots(_ reader: BufferReader) -> PrivacyRule? {
|
||||||
|
return Api.PrivacyRule.privacyValueDisallowBots
|
||||||
|
}
|
||||||
public static func parse_privacyValueDisallowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
|
public static func parse_privacyValueDisallowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
|
||||||
var _1: [Int64]?
|
var _1: [Int64]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
|
@ -35,8 +35,8 @@ public final class SelectivePrivacyPeer: Equatable {
|
|||||||
|
|
||||||
public enum SelectivePrivacySettings: Equatable {
|
public enum SelectivePrivacySettings: Equatable {
|
||||||
case enableEveryone(disableFor: [PeerId: SelectivePrivacyPeer])
|
case enableEveryone(disableFor: [PeerId: SelectivePrivacyPeer])
|
||||||
case enableContacts(enableFor: [PeerId: SelectivePrivacyPeer], disableFor: [PeerId: SelectivePrivacyPeer], enableForPremium: Bool)
|
case enableContacts(enableFor: [PeerId: SelectivePrivacyPeer], disableFor: [PeerId: SelectivePrivacyPeer], enableForPremium: Bool, enableForBots: Bool)
|
||||||
case disableEveryone(enableFor: [PeerId: SelectivePrivacyPeer], enableForCloseFriends: Bool, enableForPremium: Bool)
|
case disableEveryone(enableFor: [PeerId: SelectivePrivacyPeer], enableForCloseFriends: Bool, enableForPremium: Bool, enableForBots: Bool)
|
||||||
|
|
||||||
public static func ==(lhs: SelectivePrivacySettings, rhs: SelectivePrivacySettings) -> Bool {
|
public static func ==(lhs: SelectivePrivacySettings, rhs: SelectivePrivacySettings) -> Bool {
|
||||||
switch lhs {
|
switch lhs {
|
||||||
@ -46,14 +46,14 @@ public enum SelectivePrivacySettings: Equatable {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||||
if case .enableContacts(enableFor, disableFor, enableForPremium) = rhs {
|
if case .enableContacts(enableFor, disableFor, enableForPremium, enableForBots) = rhs {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||||
if case .disableEveryone(enableFor, enableForCloseFriends, enableForPremium) = rhs {
|
if case .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots) = rhs {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -63,10 +63,10 @@ public enum SelectivePrivacySettings: Equatable {
|
|||||||
|
|
||||||
func withEnabledPeers(_ peers: [PeerId: SelectivePrivacyPeer]) -> SelectivePrivacySettings {
|
func withEnabledPeers(_ peers: [PeerId: SelectivePrivacyPeer]) -> SelectivePrivacySettings {
|
||||||
switch self {
|
switch self {
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||||
return .disableEveryone(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium)
|
return .disableEveryone(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||||
return .enableContacts(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), disableFor: disableFor, enableForPremium: enableForPremium)
|
return .enableContacts(enableFor: enableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), disableFor: disableFor, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||||
case .enableEveryone:
|
case .enableEveryone:
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
@ -76,8 +76,8 @@ public enum SelectivePrivacySettings: Equatable {
|
|||||||
switch self {
|
switch self {
|
||||||
case .disableEveryone:
|
case .disableEveryone:
|
||||||
return self
|
return self
|
||||||
case let .enableContacts(enableFor, disableFor, enableForPremium):
|
case let .enableContacts(enableFor, disableFor, enableForPremium, enableForBots):
|
||||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForPremium: enableForPremium)
|
return .enableContacts(enableFor: enableFor, disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }), enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||||
case let .enableEveryone(disableFor):
|
case let .enableEveryone(disableFor):
|
||||||
return .enableEveryone(disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }))
|
return .enableEveryone(disableFor: disableFor.merging(peers, uniquingKeysWith: { lhs, rhs in lhs }))
|
||||||
}
|
}
|
||||||
@ -85,10 +85,10 @@ public enum SelectivePrivacySettings: Equatable {
|
|||||||
|
|
||||||
func withEnableForPremium(_ enableForPremium: Bool) -> SelectivePrivacySettings {
|
func withEnableForPremium(_ enableForPremium: Bool) -> SelectivePrivacySettings {
|
||||||
switch self {
|
switch self {
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, _):
|
case let .disableEveryone(enableFor, enableForCloseFriends, _, enableForBots):
|
||||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium)
|
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||||
case let .enableContacts(enableFor, disableFor, _):
|
case let .enableContacts(enableFor, disableFor, _, enableForBots):
|
||||||
return .enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: enableForPremium)
|
return .enableContacts(enableFor: enableFor, disableFor: disableFor, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||||
case .enableEveryone:
|
case .enableEveryone:
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
@ -96,14 +96,25 @@ public enum SelectivePrivacySettings: Equatable {
|
|||||||
|
|
||||||
func withEnableForCloseFriends(_ enableForCloseFriends: Bool) -> SelectivePrivacySettings {
|
func withEnableForCloseFriends(_ enableForCloseFriends: Bool) -> SelectivePrivacySettings {
|
||||||
switch self {
|
switch self {
|
||||||
case let .disableEveryone(enableFor, _, enableForPremium):
|
case let .disableEveryone(enableFor, _, enableForPremium, enableForBots):
|
||||||
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium)
|
return .disableEveryone(enableFor: enableFor, enableForCloseFriends: enableForCloseFriends, enableForPremium: enableForPremium, enableForBots: enableForBots)
|
||||||
case .enableContacts:
|
case .enableContacts:
|
||||||
return self
|
return self
|
||||||
case .enableEveryone:
|
case .enableEveryone:
|
||||||
return self
|
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 {
|
public struct AccountPrivacySettings: Equatable {
|
||||||
@ -118,12 +129,13 @@ public struct AccountPrivacySettings: Equatable {
|
|||||||
public var voiceMessages: SelectivePrivacySettings
|
public var voiceMessages: SelectivePrivacySettings
|
||||||
public var bio: SelectivePrivacySettings
|
public var bio: SelectivePrivacySettings
|
||||||
public var birthday: SelectivePrivacySettings
|
public var birthday: SelectivePrivacySettings
|
||||||
|
public var giftsAutoSave: SelectivePrivacySettings
|
||||||
|
|
||||||
public var globalSettings: GlobalPrivacySettings
|
public var globalSettings: GlobalPrivacySettings
|
||||||
public var accountRemovalTimeout: Int32
|
public var accountRemovalTimeout: Int32
|
||||||
public var messageAutoremoveTimeout: 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.presence = presence
|
||||||
self.groupInvitations = groupInvitations
|
self.groupInvitations = groupInvitations
|
||||||
self.voiceCalls = voiceCalls
|
self.voiceCalls = voiceCalls
|
||||||
@ -135,6 +147,7 @@ public struct AccountPrivacySettings: Equatable {
|
|||||||
self.voiceMessages = voiceMessages
|
self.voiceMessages = voiceMessages
|
||||||
self.bio = bio
|
self.bio = bio
|
||||||
self.birthday = birthday
|
self.birthday = birthday
|
||||||
|
self.giftsAutoSave = giftsAutoSave
|
||||||
self.globalSettings = globalSettings
|
self.globalSettings = globalSettings
|
||||||
self.accountRemovalTimeout = accountRemovalTimeout
|
self.accountRemovalTimeout = accountRemovalTimeout
|
||||||
self.messageAutoremoveTimeout = messageAutoremoveTimeout
|
self.messageAutoremoveTimeout = messageAutoremoveTimeout
|
||||||
@ -174,6 +187,9 @@ public struct AccountPrivacySettings: Equatable {
|
|||||||
if lhs.birthday != rhs.birthday {
|
if lhs.birthday != rhs.birthday {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.giftsAutoSave != rhs.giftsAutoSave {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.globalSettings != rhs.globalSettings {
|
if lhs.globalSettings != rhs.globalSettings {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -190,19 +206,20 @@ public struct AccountPrivacySettings: Equatable {
|
|||||||
|
|
||||||
extension SelectivePrivacySettings {
|
extension SelectivePrivacySettings {
|
||||||
init(apiRules: [Api.PrivacyRule], peers: [PeerId: SelectivePrivacyPeer]) {
|
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 disableFor: [PeerId: SelectivePrivacyPeer] = [:]
|
||||||
var enableFor: [PeerId: SelectivePrivacyPeer] = [:]
|
var enableFor: [PeerId: SelectivePrivacyPeer] = [:]
|
||||||
var enableForCloseFriends: Bool = false
|
var enableForCloseFriends: Bool = false
|
||||||
var enableForPremium: Bool = false
|
var enableForPremium: Bool = false
|
||||||
|
var enableForBots: Bool?
|
||||||
|
|
||||||
for rule in apiRules {
|
for rule in apiRules {
|
||||||
switch rule {
|
switch rule {
|
||||||
case .privacyValueAllowAll:
|
case .privacyValueAllowAll:
|
||||||
current = .enableEveryone(disableFor: [:])
|
current = .enableEveryone(disableFor: [:])
|
||||||
case .privacyValueAllowContacts:
|
case .privacyValueAllowContacts:
|
||||||
current = .enableContacts(enableFor: [:], disableFor: [:], enableForPremium: false)
|
current = .enableContacts(enableFor: [:], disableFor: [:], enableForPremium: false, enableForBots: false)
|
||||||
case let .privacyValueAllowUsers(users):
|
case let .privacyValueAllowUsers(users):
|
||||||
for id in users {
|
for id in users {
|
||||||
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))] {
|
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))] {
|
||||||
@ -239,10 +256,14 @@ extension SelectivePrivacySettings {
|
|||||||
enableForCloseFriends = true
|
enableForCloseFriends = true
|
||||||
case .privacyValueAllowPremium:
|
case .privacyValueAllowPremium:
|
||||||
enableForPremium = true
|
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 voiceMessagesPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyVoiceMessages))
|
||||||
let bioPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyAbout))
|
let bioPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyAbout))
|
||||||
let birthdayPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyBirthday))
|
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 autoremoveTimeout = account.network.request(Api.functions.account.getAccountTTL())
|
||||||
let globalPrivacySettings = account.network.request(Api.functions.account.getGlobalPrivacySettings())
|
let globalPrivacySettings = account.network.request(Api.functions.account.getGlobalPrivacySettings())
|
||||||
let messageAutoremoveTimeout = account.network.request(Api.functions.messages.getDefaultHistoryTTL())
|
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
|
|> `catch` { _ in
|
||||||
return .complete()
|
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
|
let accountTimeoutSeconds: Int32
|
||||||
switch autoremoveTimeout {
|
switch autoremoveTimeout {
|
||||||
case let .accountDaysTTL(days):
|
case let .accountDaysTTL(days):
|
||||||
@ -86,6 +87,7 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
|||||||
let voiceMessagesRules: [Api.PrivacyRule]
|
let voiceMessagesRules: [Api.PrivacyRule]
|
||||||
let bioRules: [Api.PrivacyRule]
|
let bioRules: [Api.PrivacyRule]
|
||||||
let birthdayRules: [Api.PrivacyRule]
|
let birthdayRules: [Api.PrivacyRule]
|
||||||
|
let giftsAutoSaveRules: [Api.PrivacyRule]
|
||||||
var apiUsers: [Api.User] = []
|
var apiUsers: [Api.User] = []
|
||||||
var apiChats: [Api.Chat] = []
|
var apiChats: [Api.Chat] = []
|
||||||
|
|
||||||
@ -172,6 +174,13 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
|
|||||||
birthdayRules = rules
|
birthdayRules = rules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch giftsAutoSavePrivacy {
|
||||||
|
case let .privacyRules(rules, chats, users):
|
||||||
|
apiUsers.append(contentsOf: users)
|
||||||
|
apiChats.append(contentsOf: chats)
|
||||||
|
giftsAutoSaveRules = rules
|
||||||
|
}
|
||||||
|
|
||||||
var peers: [SelectivePrivacyPeer] = []
|
var peers: [SelectivePrivacyPeer] = []
|
||||||
for user in apiUsers {
|
for user in apiUsers {
|
||||||
peers.append(SelectivePrivacyPeer(peer: TelegramUser(user: user), participantCount: nil))
|
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),
|
voiceMessages: SelectivePrivacySettings(apiRules: voiceMessagesRules, peers: peerMap),
|
||||||
bio: SelectivePrivacySettings(apiRules: bioRules, peers: peerMap),
|
bio: SelectivePrivacySettings(apiRules: bioRules, peers: peerMap),
|
||||||
birthday: SelectivePrivacySettings(apiRules: birthdayRules, peers: peerMap),
|
birthday: SelectivePrivacySettings(apiRules: birthdayRules, peers: peerMap),
|
||||||
|
giftsAutoSave: SelectivePrivacySettings(apiRules: giftsAutoSaveRules, peers: peerMap),
|
||||||
globalSettings: globalSettings,
|
globalSettings: globalSettings,
|
||||||
accountRemovalTimeout: accountTimeoutSeconds,
|
accountRemovalTimeout: accountTimeoutSeconds,
|
||||||
messageAutoremoveTimeout: messageAutoremoveSeconds
|
messageAutoremoveTimeout: messageAutoremoveSeconds
|
||||||
@ -371,6 +381,7 @@ public enum UpdateSelectiveAccountPrivacySettingsType {
|
|||||||
case voiceMessages
|
case voiceMessages
|
||||||
case bio
|
case bio
|
||||||
case birthday
|
case birthday
|
||||||
|
case giftsAutoSave
|
||||||
|
|
||||||
var apiKey: Api.InputPrivacyKey {
|
var apiKey: Api.InputPrivacyKey {
|
||||||
switch self {
|
switch self {
|
||||||
@ -394,6 +405,8 @@ public enum UpdateSelectiveAccountPrivacySettingsType {
|
|||||||
return .inputPrivacyKeyAbout
|
return .inputPrivacyKeyAbout
|
||||||
case .birthday:
|
case .birthday:
|
||||||
return .inputPrivacyKeyBirthday
|
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
|
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||||
var rules: [Api.InputPrivacyRule] = []
|
var rules: [Api.InputPrivacyRule] = []
|
||||||
switch settings {
|
switch settings {
|
||||||
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium):
|
case let .disableEveryone(enableFor, enableForCloseFriends, enableForPremium, enableForBots):
|
||||||
let enablePeers = apiUserAndGroupIds(peerIds: enableFor)
|
let enablePeers = apiUserAndGroupIds(peerIds: enableFor)
|
||||||
|
|
||||||
if !enablePeers.users.isEmpty {
|
if !enablePeers.users.isEmpty {
|
||||||
@ -442,7 +455,10 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd
|
|||||||
if enableForPremium {
|
if enableForPremium {
|
||||||
rules.append(.inputPrivacyValueAllowPremium)
|
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 enablePeers = apiUserAndGroupIds(peerIds: enableFor)
|
||||||
let disablePeers = apiUserAndGroupIds(peerIds: disableFor)
|
let disablePeers = apiUserAndGroupIds(peerIds: disableFor)
|
||||||
|
|
||||||
@ -464,7 +480,9 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd
|
|||||||
if enableForPremium {
|
if enableForPremium {
|
||||||
rules.append(.inputPrivacyValueAllowPremium)
|
rules.append(.inputPrivacyValueAllowPremium)
|
||||||
}
|
}
|
||||||
let _ = enableForPremium
|
if enableForBots {
|
||||||
|
rules.append(.inputPrivacyValueAllowBots)
|
||||||
|
}
|
||||||
case let .enableEveryone(disableFor):
|
case let .enableEveryone(disableFor):
|
||||||
let disablePeers = apiUserAndGroupIds(peerIds: disableFor)
|
let disablePeers = apiUserAndGroupIds(peerIds: disableFor)
|
||||||
|
|
||||||
|
@ -2458,7 +2458,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
let presence = current.presence
|
let presence = current.presence
|
||||||
var disabledFor: [PeerId: SelectivePrivacyPeer] = [:]
|
var disabledFor: [PeerId: SelectivePrivacyPeer] = [:]
|
||||||
switch presence {
|
switch presence {
|
||||||
case let .enableEveryone(disabledForValue), let .enableContacts(_, disabledForValue, _):
|
case let .enableEveryone(disabledForValue), let .enableContacts(_, disabledForValue, _, _):
|
||||||
disabledFor = disabledForValue
|
disabledFor = disabledForValue
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
@ -249,12 +249,24 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
let placeholder: Signal<(FileMediaReference, Bool)?, NoError>
|
let placeholder: Signal<(FileMediaReference, Bool)?, NoError>
|
||||||
if let botAppSettings = controller.botAppSettings {
|
if let botAppSettings = controller.botAppSettings {
|
||||||
Queue.mainQueue().justDispatch {
|
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.appBackgroundColor = UIColor(rgb: UInt32(bitPattern: backgroundColor))
|
||||||
self.placeholderBackgroundColor = self.appBackgroundColor
|
self.placeholderBackgroundColor = self.appBackgroundColor
|
||||||
self.updateBackgroundColor(transition: .immediate)
|
self.updateBackgroundColor(transition: .immediate)
|
||||||
}
|
}
|
||||||
if let headerColor = botAppSettings.headerColor {
|
if let headerColor {
|
||||||
self.headerColor = UIColor(rgb: UInt32(bitPattern: headerColor))
|
self.headerColor = UIColor(rgb: UInt32(bitPattern: headerColor))
|
||||||
self.updateHeaderBackgroundColor(transition: .immediate)
|
self.updateHeaderBackgroundColor(transition: .immediate)
|
||||||
}
|
}
|
||||||
@ -2131,14 +2143,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
if let refreshRate {
|
if let refreshRate {
|
||||||
self.motionManager.accelerometerUpdateInterval = refreshRate * 0.001
|
self.motionManager.accelerometerUpdateInterval = refreshRate * 0.001
|
||||||
}
|
}
|
||||||
self.motionManager.startAccelerometerUpdates(to: OperationQueue.main) { data, error in
|
self.motionManager.startAccelerometerUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||||
if let data = data {
|
guard let self, let data else {
|
||||||
let gravityConstant = 9.81
|
return
|
||||||
self.webView?.sendEvent(
|
|
||||||
name: "accelerometer_changed",
|
|
||||||
data: "{x: \(data.acceleration.x * gravityConstant), y: \(data.acceleration.y * gravityConstant), z: \(data.acceleration.z * gravityConstant)}"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
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 {
|
} else {
|
||||||
if self.motionManager.isAccelerometerActive {
|
if self.motionManager.isAccelerometerActive {
|
||||||
@ -2164,13 +2177,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
if let refreshRate {
|
if let refreshRate {
|
||||||
self.motionManager.deviceMotionUpdateInterval = refreshRate * 0.001
|
self.motionManager.deviceMotionUpdateInterval = refreshRate * 0.001
|
||||||
}
|
}
|
||||||
self.motionManager.startDeviceMotionUpdates(to: OperationQueue.main) { data, error in
|
self.motionManager.startDeviceMotionUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||||
if let data {
|
guard let self, let data else {
|
||||||
self.webView?.sendEvent(
|
return
|
||||||
name: "device_orientation_changed",
|
|
||||||
data: "{alpha: \(data.attitude.roll), beta: \(data.attitude.pitch), gamma: \(data.attitude.yaw)}"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
self.webView?.sendEvent(
|
||||||
|
name: "device_orientation_changed",
|
||||||
|
data: "{alpha: \(data.attitude.roll), beta: \(data.attitude.pitch), gamma: \(data.attitude.yaw)}"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if self.motionManager.isDeviceMotionActive {
|
if self.motionManager.isDeviceMotionActive {
|
||||||
@ -2196,13 +2210,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
if let refreshRate {
|
if let refreshRate {
|
||||||
self.motionManager.gyroUpdateInterval = refreshRate * 0.001
|
self.motionManager.gyroUpdateInterval = refreshRate * 0.001
|
||||||
}
|
}
|
||||||
self.motionManager.startGyroUpdates(to: OperationQueue.main) { data, error in
|
self.motionManager.startGyroUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||||
if let data {
|
guard let self, let data else {
|
||||||
self.webView?.sendEvent(
|
return
|
||||||
name: "gyroscope_changed",
|
|
||||||
data: "{x: \(data.rotationRate.x), y: \(data.rotationRate.y), z: \(data.rotationRate.z)}"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
self.webView?.sendEvent(
|
||||||
|
name: "gyroscope_changed",
|
||||||
|
data: "{x: \(data.rotationRate.x), y: \(data.rotationRate.y), z: \(data.rotationRate.z)}"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if self.motionManager.isGyroActive {
|
if self.motionManager.isGyroActive {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user