mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Stories
This commit is contained in:
@@ -25,6 +25,10 @@ public extension TelegramEngine {
|
||||
return _internal_requestAccountPrivacySettings(account: self.account)
|
||||
}
|
||||
|
||||
public func updateGlobalPrivacySettings() -> Signal<Never, NoError> {
|
||||
return _internal_updateGlobalPrivacySettings(account: self.account)
|
||||
}
|
||||
|
||||
public func updateAccountAutoArchiveChats(value: Bool) -> Signal<Never, NoError> {
|
||||
return _internal_updateAccountAutoArchiveChats(account: self.account, value: value)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,36 @@ import Postbox
|
||||
import TelegramApi
|
||||
import SwiftSignalKit
|
||||
|
||||
func _internal_updateGlobalPrivacySettings(account: Account) -> Signal<Never, NoError> {
|
||||
return account.network.request(Api.functions.account.getGlobalPrivacySettings())
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.GlobalPrivacySettings?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
guard let result = result else {
|
||||
return
|
||||
}
|
||||
let globalSettings: GlobalPrivacySettings
|
||||
switch result {
|
||||
case let .globalPrivacySettings(flags):
|
||||
let automaticallyArchiveAndMuteNonContacts = (flags & (1 << 0)) != 0
|
||||
let keepArchivedUnmuted = (flags & (1 << 1)) != 0
|
||||
let keepArchivedFolders = (flags & (1 << 2)) != 0
|
||||
globalSettings = GlobalPrivacySettings(
|
||||
automaticallyArchiveAndMuteNonContacts: automaticallyArchiveAndMuteNonContacts,
|
||||
keepArchivedUnmuted: keepArchivedUnmuted,
|
||||
keepArchivedFolders: keepArchivedFolders
|
||||
)
|
||||
}
|
||||
updateGlobalPrivacySettings(transaction: transaction, { _ in
|
||||
return globalSettings
|
||||
})
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_requestAccountPrivacySettings(account: Account) -> Signal<AccountPrivacySettings, NoError> {
|
||||
let lastSeenPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyStatusTimestamp))
|
||||
|
||||
Reference in New Issue
Block a user