mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Update API
This commit is contained in:
@@ -31,6 +31,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
let openPhoneNumberPrivacy: () -> Void
|
||||
let openVoiceMessagePrivacy: () -> Void
|
||||
let openBioPrivacy: () -> Void
|
||||
let openBirthdayPrivacy: () -> Void
|
||||
let openPasscode: () -> Void
|
||||
let openTwoStepVerification: (TwoStepVerificationAccessConfiguration?) -> Void
|
||||
let openActiveSessions: () -> Void
|
||||
@@ -41,7 +42,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
let openEmailSettings: (String?) -> Void
|
||||
let openMessagePrivacy: () -> 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, 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) {
|
||||
self.account = account
|
||||
self.openBlockedUsers = openBlockedUsers
|
||||
self.openLastSeenPrivacy = openLastSeenPrivacy
|
||||
@@ -52,6 +53,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
self.openPhoneNumberPrivacy = openPhoneNumberPrivacy
|
||||
self.openVoiceMessagePrivacy = openVoiceMessagePrivacy
|
||||
self.openBioPrivacy = openBioPrivacy
|
||||
self.openBirthdayPrivacy = openBirthdayPrivacy
|
||||
self.openPasscode = openPasscode
|
||||
self.openTwoStepVerification = openTwoStepVerification
|
||||
self.openActiveSessions = openActiveSessions
|
||||
@@ -99,6 +101,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
case voiceMessagePrivacy(PresentationTheme, String, String, Bool)
|
||||
case messagePrivacy(PresentationTheme, Bool, Bool)
|
||||
case bioPrivacy(PresentationTheme, String, String)
|
||||
case birthdayPrivacy(PresentationTheme, String, String)
|
||||
case selectivePrivacyInfo(PresentationTheme, String)
|
||||
case passcode(PresentationTheme, String, Bool, String)
|
||||
case twoStepVerification(PresentationTheme, String, String, TwoStepVerificationAccessConfiguration?)
|
||||
@@ -120,7 +123,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
switch self {
|
||||
case .blockedPeers, .activeSessions, .passcode, .twoStepVerification, .loginEmail, .loginEmailInfo, .messageAutoremoveTimeout, .messageAutoremoveInfo:
|
||||
return PrivacyAndSecuritySection.general.rawValue
|
||||
case .privacyHeader, .phoneNumberPrivacy, .lastSeenPrivacy, .profilePhotoPrivacy, .forwardPrivacy, .groupPrivacy, .voiceCallPrivacy, .voiceMessagePrivacy, .messagePrivacy, .bioPrivacy, .selectivePrivacyInfo:
|
||||
case .privacyHeader, .phoneNumberPrivacy, .lastSeenPrivacy, .profilePhotoPrivacy, .forwardPrivacy, .groupPrivacy, .voiceCallPrivacy, .voiceMessagePrivacy, .messagePrivacy, .bioPrivacy, .birthdayPrivacy, .selectivePrivacyInfo:
|
||||
return PrivacyAndSecuritySection.privacy.rawValue
|
||||
case .autoArchiveHeader, .autoArchive, .autoArchiveInfo:
|
||||
return PrivacyAndSecuritySection.autoArchive.rawValue
|
||||
@@ -159,34 +162,36 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return 12
|
||||
case .bioPrivacy:
|
||||
return 13
|
||||
case .forwardPrivacy:
|
||||
case .birthdayPrivacy:
|
||||
return 14
|
||||
case .voiceCallPrivacy:
|
||||
case .forwardPrivacy:
|
||||
return 15
|
||||
case .groupPrivacy:
|
||||
case .voiceCallPrivacy:
|
||||
return 16
|
||||
case .voiceMessagePrivacy:
|
||||
case .groupPrivacy:
|
||||
return 17
|
||||
case .messagePrivacy:
|
||||
case .voiceMessagePrivacy:
|
||||
return 18
|
||||
case .selectivePrivacyInfo:
|
||||
case .messagePrivacy:
|
||||
return 19
|
||||
case .autoArchiveHeader:
|
||||
case .selectivePrivacyInfo:
|
||||
return 20
|
||||
case .autoArchive:
|
||||
case .autoArchiveHeader:
|
||||
return 21
|
||||
case .autoArchiveInfo:
|
||||
case .autoArchive:
|
||||
return 22
|
||||
case .autoArchiveInfo:
|
||||
return 23
|
||||
case .accountHeader:
|
||||
return 25
|
||||
return 24
|
||||
case .accountTimeout:
|
||||
return 26
|
||||
return 25
|
||||
case .accountInfo:
|
||||
return 27
|
||||
return 26
|
||||
case .dataSettings:
|
||||
return 28
|
||||
return 27
|
||||
case .dataSettingsInfo:
|
||||
return 29
|
||||
return 28
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,6 +263,12 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .birthdayPrivacy(lhsTheme, lhsText, lhsValue):
|
||||
if case let .birthdayPrivacy(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .selectivePrivacyInfo(lhsTheme, lhsText):
|
||||
if case let .selectivePrivacyInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
@@ -402,6 +413,10 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openBioPrivacy()
|
||||
})
|
||||
case let .birthdayPrivacy(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openBirthdayPrivacy()
|
||||
})
|
||||
case let .selectivePrivacyInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .voiceCallPrivacy(_, text, value):
|
||||
@@ -612,6 +627,7 @@ private func privacyAndSecurityControllerEntries(
|
||||
entries.append(.lastSeenPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_LastSeen, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.presence)))
|
||||
entries.append(.profilePhotoPrivacy(presentationData.theme, presentationData.strings.Privacy_ProfilePhoto, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.profilePhoto)))
|
||||
entries.append(.bioPrivacy(presentationData.theme, presentationData.strings.Privacy_Bio, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.bio)))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.birthday)))
|
||||
entries.append(.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(.groupPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.groupInvitations)))
|
||||
@@ -624,6 +640,7 @@ private func privacyAndSecurityControllerEntries(
|
||||
entries.append(.lastSeenPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_LastSeen, 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(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.groupPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, presentationData.strings.Channel_NotificationLoading))
|
||||
@@ -1011,6 +1028,29 @@ public func privacyAndSecurityController(
|
||||
}), true)
|
||||
}
|
||||
}))
|
||||
}, openBirthdayPrivacy: {
|
||||
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: .birthday, current: info.birthday, 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: updated, globalSettings: value.globalSettings, accountRemovalTimeout: value.accountRemovalTimeout, messageAutoremoveTimeout: value.messageAutoremoveTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
currentInfoDisposable.set(applySetting.start())
|
||||
}
|
||||
}), true)
|
||||
}
|
||||
}))
|
||||
}, openPasscode: {
|
||||
let _ = passcodeOptionsAccessController(context: context, pushController: { controller in
|
||||
replaceTopControllerImpl?(controller)
|
||||
|
||||
Reference in New Issue
Block a user