mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Merge commit '28394131a53041b7b986a8477f6c1089a289d785'
This commit is contained in:
commit
d731df8b34
@ -130,9 +130,8 @@ public func initialAvatarGalleryEntries(account: Account, peer: Peer) -> Signal<
|
||||
initialPhoto = photo
|
||||
}
|
||||
|
||||
if let photo = initialPhoto {
|
||||
if let photo = initialPhoto, !photo.videoRepresentations.isEmpty {
|
||||
return [.topImage(photo.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.standalone(resource: $0.resource)) }), photo.videoRepresentations, nil, nil, nil)]
|
||||
// return [.image(photo.imageId, photo.reference, photo.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.standalone(resource: $0.resource)) }), photo.videoRepresentations, peer, 0, nil, nil, photo.immediateThumbnailData, nil)]
|
||||
} else {
|
||||
return initialEntries
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ public func channelAdminsController(context: AccountContext, peerId initialPeerI
|
||||
return controller
|
||||
}
|
||||
|
||||
func rebuildControllerStackAfterSupergroupUpgrade(controller: ViewController, navigationController: NavigationController, replace: ((UIViewController) -> UIViewController)? = nil) {
|
||||
public func rebuildControllerStackAfterSupergroupUpgrade(controller: ViewController, navigationController: NavigationController, replace: ((UIViewController) -> UIViewController)? = nil) {
|
||||
var controllers = navigationController.viewControllers
|
||||
for i in 0 ..< controllers.count {
|
||||
if controllers[i] === controller {
|
||||
|
@ -94,9 +94,9 @@ final class PeerInfoState {
|
||||
final class TelegramGlobalSettings {
|
||||
let suggestPhoneNumberConfirmation: Bool
|
||||
let accountsAndPeers: [(Account, Peer, Int32)]
|
||||
let activeSessionsContext: ActiveSessionsContext
|
||||
let webSessionsContext: WebSessionsContext
|
||||
let otherSessionsCount: Int
|
||||
let activeSessionsContext: ActiveSessionsContext?
|
||||
let webSessionsContext: WebSessionsContext?
|
||||
let otherSessionsCount: Int?
|
||||
let proxySettings: ProxySettings
|
||||
let notificationAuthorizationStatus: AccessType
|
||||
let notificationWarningSuppressed: Bool
|
||||
@ -112,9 +112,9 @@ final class TelegramGlobalSettings {
|
||||
init(
|
||||
suggestPhoneNumberConfirmation: Bool,
|
||||
accountsAndPeers: [(Account, Peer, Int32)],
|
||||
activeSessionsContext: ActiveSessionsContext,
|
||||
webSessionsContext: WebSessionsContext,
|
||||
otherSessionsCount: Int,
|
||||
activeSessionsContext: ActiveSessionsContext?,
|
||||
webSessionsContext: WebSessionsContext?,
|
||||
otherSessionsCount: Int?,
|
||||
proxySettings: ProxySettings,
|
||||
notificationAuthorizationStatus: AccessType,
|
||||
notificationWarningSuppressed: Bool,
|
||||
@ -366,7 +366,7 @@ func keepPeerInfoScreenDataHot(context: AccountContext, peerId: PeerId) -> Signa
|
||||
}
|
||||
}
|
||||
|
||||
func peerInfoScreenSettingsData(context: AccountContext, peerId: PeerId, accountsAndPeers: Signal<[(Account, Peer, Int32)], NoError>, activeSessionsContextAndCount: Signal<(ActiveSessionsContext, Int, WebSessionsContext), NoError>, notificationExceptions: Signal<NotificationExceptionsList?, NoError>, privacySettings: Signal<AccountPrivacySettings?, NoError>, archivedStickerPacks: Signal<[ArchivedStickerPackItem]?, NoError>, hasPassport: Signal<Bool, NoError>) -> Signal<PeerInfoScreenData, NoError> {
|
||||
func peerInfoScreenSettingsData(context: AccountContext, peerId: PeerId, accountsAndPeers: Signal<[(Account, Peer, Int32)], NoError>, activeSessionsContextAndCount: Signal<(ActiveSessionsContext, Int, WebSessionsContext)?, NoError>, notificationExceptions: Signal<NotificationExceptionsList?, NoError>, privacySettings: Signal<AccountPrivacySettings?, NoError>, archivedStickerPacks: Signal<[ArchivedStickerPackItem]?, NoError>, hasPassport: Signal<Bool, NoError>) -> Signal<PeerInfoScreenData, NoError> {
|
||||
let preferences = context.sharedContext.accountManager.sharedData(keys: [
|
||||
SharedDataKeys.proxySettings,
|
||||
ApplicationSpecificSharedDataKeys.inAppNotificationSettings,
|
||||
@ -428,7 +428,7 @@ func peerInfoScreenSettingsData(context: AccountContext, peerId: PeerId, account
|
||||
enableQRLogin = true
|
||||
}
|
||||
|
||||
let globalSettings = TelegramGlobalSettings(suggestPhoneNumberConfirmation: false, accountsAndPeers: accountsAndPeers, activeSessionsContext: accountSessions.0, webSessionsContext: accountSessions.2, otherSessionsCount: accountSessions.1, proxySettings: proxySettings, notificationAuthorizationStatus: notificationsAuthorizationStatus, notificationWarningSuppressed: notificationsWarningSuppressed, notificationExceptions: notificationExceptions, inAppNotificationSettings: inAppNotificationSettings, privacySettings: privacySettings, unreadTrendingStickerPacks: unreadTrendingStickerPacks, archivedStickerPacks: archivedStickerPacks, hasPassport: hasPassport, hasWatchApp: hasWatchApp, enableQRLogin: enableQRLogin)
|
||||
let globalSettings = TelegramGlobalSettings(suggestPhoneNumberConfirmation: false, accountsAndPeers: accountsAndPeers, activeSessionsContext: accountSessions?.0, webSessionsContext: accountSessions?.2, otherSessionsCount: accountSessions?.1, proxySettings: proxySettings, notificationAuthorizationStatus: notificationsAuthorizationStatus, notificationWarningSuppressed: notificationsWarningSuppressed, notificationExceptions: notificationExceptions, inAppNotificationSettings: inAppNotificationSettings, privacySettings: privacySettings, unreadTrendingStickerPacks: unreadTrendingStickerPacks, archivedStickerPacks: archivedStickerPacks, hasPassport: hasPassport, hasWatchApp: hasWatchApp, enableQRLogin: enableQRLogin)
|
||||
|
||||
return PeerInfoScreenData(
|
||||
peer: peerView.peers[peerId],
|
||||
|
@ -1320,8 +1320,9 @@ final class PeerInfoEditingAvatarOverlayNode: ASDisplayNode {
|
||||
overlayHidden = true
|
||||
}
|
||||
|
||||
let targetAlpha: CGFloat = overlayHidden ? 0.0 : 1.0
|
||||
if self.updatingAvatarOverlay.alpha != targetAlpha {
|
||||
let targetIconAlpha: CGFloat = iconHidden ? 0.0 : 1.0
|
||||
let targetOverlayAlpha: CGFloat = overlayHidden ? 0.0 : 1.0
|
||||
if self.updatingAvatarOverlay.alpha != targetOverlayAlpha || self.iconNode.alpha != targetIconAlpha {
|
||||
let update = {
|
||||
self.statusNode.transitionToState(.none)
|
||||
self.currentRepresentation = nil
|
||||
@ -2290,6 +2291,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
|
||||
private(set) var isAvatarExpanded: Bool
|
||||
private(set) var twoLineInfo = false
|
||||
var skipCollapseCompletion = false
|
||||
|
||||
let avatarListNode: PeerInfoAvatarListNode
|
||||
|
||||
@ -2753,8 +2755,10 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
}
|
||||
strongSelf.avatarListNode.avatarContainerNode.canAttachVideo = true
|
||||
strongSelf.avatarListNode.listContainerNode.isHidden = true
|
||||
DispatchQueue.main.async {
|
||||
strongSelf.avatarListNode.listContainerNode.isCollapsing = false
|
||||
if !strongSelf.skipCollapseCompletion {
|
||||
DispatchQueue.main.async {
|
||||
strongSelf.avatarListNode.listContainerNode.isCollapsing = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import DeviceAccess
|
||||
import LegacyMediaPickerUI
|
||||
import TelegramNotices
|
||||
import SaveToCameraRoll
|
||||
import PeerInfoUI
|
||||
|
||||
protocol PeerInfoScreenItem: class {
|
||||
var id: AnyHashable { get }
|
||||
@ -712,11 +713,11 @@ private func settingsItems(data: PeerInfoScreenData?, context: AccountContext, p
|
||||
}))
|
||||
|
||||
let devicesLabel: String
|
||||
if let settings = data.globalSettings {
|
||||
if let settings = data.globalSettings, let otherSessionsCount = settings.otherSessionsCount {
|
||||
if settings.enableQRLogin {
|
||||
devicesLabel = settings.otherSessionsCount == 0 ? presentationData.strings.Settings_AddDevice : "\(settings.otherSessionsCount + 1)"
|
||||
devicesLabel = otherSessionsCount == 0 ? presentationData.strings.Settings_AddDevice : "\(otherSessionsCount + 1)"
|
||||
} else {
|
||||
devicesLabel = settings.otherSessionsCount == 0 ? "" : "\(settings.otherSessionsCount + 1)"
|
||||
devicesLabel = otherSessionsCount == 0 ? "" : "\(otherSessionsCount + 1)"
|
||||
}
|
||||
} else {
|
||||
devicesLabel = ""
|
||||
@ -1392,7 +1393,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
private let preloadStickerDisposable = MetaDisposable()
|
||||
|
||||
fileprivate let accountsAndPeers = Promise<[(Account, Peer, Int32)]>()
|
||||
private let activeSessionsContextAndCount = Promise<(ActiveSessionsContext, Int, WebSessionsContext)>()
|
||||
fileprivate let activeSessionsContextAndCount = Promise<(ActiveSessionsContext, Int, WebSessionsContext)?>()
|
||||
private let notificationExceptions = Promise<NotificationExceptionsList?>()
|
||||
private let privacySettings = Promise<AccountPrivacySettings?>()
|
||||
private let archivedPacks = Promise<[ArchivedStickerPackItem]?>()
|
||||
@ -2181,8 +2182,10 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
var updateOnCompletion = false
|
||||
if strongSelf.headerNode.isAvatarExpanded {
|
||||
updateOnCompletion = true
|
||||
strongSelf.headerNode.skipCollapseCompletion = true
|
||||
strongSelf.headerNode.avatarListNode.avatarContainerNode.canAttachVideo = false
|
||||
strongSelf.headerNode.editingContentNode.avatarNode.canAttachVideo = false
|
||||
strongSelf.headerNode.avatarListNode.listContainerNode.isCollapsing = true
|
||||
strongSelf.headerNode.updateIsAvatarExpanded(false, transition: .immediate)
|
||||
strongSelf.updateNavigationExpansionPresentation(isExpanded: false, animated: true)
|
||||
}
|
||||
@ -2193,6 +2196,8 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
UIView.transition(with: strongSelf.view, duration: 0.3, options: [.transitionCrossDissolve], animations: {
|
||||
}, completion: { _ in
|
||||
if updateOnCompletion {
|
||||
strongSelf.headerNode.skipCollapseCompletion = false
|
||||
strongSelf.headerNode.avatarListNode.listContainerNode.isCollapsing = false
|
||||
strongSelf.headerNode.avatarListNode.avatarContainerNode.canAttachVideo = true
|
||||
strongSelf.headerNode.editingContentNode.avatarNode.canAttachVideo = true
|
||||
if let (layout, navigationHeight) = strongSelf.validLayout {
|
||||
@ -2485,20 +2490,6 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
|
||||
let screenData: Signal<PeerInfoScreenData, NoError>
|
||||
if self.isSettings {
|
||||
let activeSessionsContextAndCountSignal = deferred { () -> Signal<(ActiveSessionsContext, Int, WebSessionsContext), NoError> in
|
||||
let activeSessionsContext = ActiveSessionsContext(account: context.account)
|
||||
let webSessionsContext = WebSessionsContext(account: context.account)
|
||||
let otherSessionCount = activeSessionsContext.state
|
||||
|> map { state -> Int in
|
||||
return state.sessions.filter({ !$0.isCurrent }).count
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
return otherSessionCount
|
||||
|> map { value in
|
||||
return (activeSessionsContext, value, webSessionsContext)
|
||||
}
|
||||
}
|
||||
self.activeSessionsContextAndCount.set(activeSessionsContextAndCountSignal)
|
||||
self.notificationExceptions.set(.single(NotificationExceptionsList(peers: [:], settings: [:]))
|
||||
|> then(
|
||||
notificationExceptionsList(postbox: context.account.postbox, network: context.account.network)
|
||||
@ -3555,7 +3546,18 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
guard let data = self.data, let peer = data.peer else {
|
||||
return
|
||||
}
|
||||
self.controller?.push(groupPreHistorySetupController(context: self.context, peerId: peer.id, upgradedToSupergroup: { _, f in f() }))
|
||||
var upgradedToSupergroupImpl: (() -> Void)?
|
||||
let controller = groupPreHistorySetupController(context: self.context, peerId: peer.id, upgradedToSupergroup: { _, f in
|
||||
upgradedToSupergroupImpl?()
|
||||
f()
|
||||
})
|
||||
self.controller?.push(controller)
|
||||
|
||||
upgradedToSupergroupImpl = { [weak controller] in
|
||||
if let controller = controller, let navigationController = controller.navigationController as? NavigationController {
|
||||
rebuildControllerStackAfterSupergroupUpgrade(controller: controller, navigationController: navigationController)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func openPermissions() {
|
||||
@ -4547,7 +4549,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
let _ = (self.activeSessionsContextAndCount.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] activeSessionsContextAndCount in
|
||||
if let strongSelf = self {
|
||||
if let strongSelf = self, let activeSessionsContextAndCount = activeSessionsContextAndCount {
|
||||
let (activeSessionsContext, count, webSessionsContext) = activeSessionsContextAndCount
|
||||
if count == 0 && settings.enableQRLogin {
|
||||
strongSelf.controller?.push(AuthDataTransferSplashScreen(context: strongSelf.context, activeSessionsContext: activeSessionsContext))
|
||||
@ -4898,7 +4900,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
}
|
||||
})
|
||||
}
|
||||
}, exceptionsList: .single(settings.notificationExceptions), archivedStickerPacks: .single(settings.archivedStickerPacks), privacySettings: .single(settings.privacySettings), hasWallet: .single(false), activeSessionsContext: self.activeSessionsContextAndCount.get() |> map { $0.0 }, webSessionsContext: self.activeSessionsContextAndCount.get() |> map { $0.2 }), cancel: { [weak self] in
|
||||
}, exceptionsList: .single(settings.notificationExceptions), archivedStickerPacks: .single(settings.archivedStickerPacks), privacySettings: .single(settings.privacySettings), hasWallet: .single(false), activeSessionsContext: self.activeSessionsContextAndCount.get() |> map { $0?.0 }, webSessionsContext: self.activeSessionsContextAndCount.get() |> map { $0?.2 }), cancel: { [weak self] in
|
||||
self?.deactivateSearch()
|
||||
})
|
||||
}
|
||||
@ -5514,6 +5516,8 @@ public final class PeerInfoScreen: ViewController {
|
||||
private let accountsAndPeers = Promise<((Account, Peer)?, [(Account, Peer, Int32)])>()
|
||||
private var accountsAndPeersValue: ((Account, Peer)?, [(Account, Peer, Int32)])?
|
||||
private var accountsAndPeersDisposable: Disposable?
|
||||
|
||||
private let activeSessionsContextAndCount = Promise<(ActiveSessionsContext, Int, WebSessionsContext)?>(nil)
|
||||
|
||||
private var tabBarItemDisposable: Disposable?
|
||||
|
||||
@ -5554,8 +5558,22 @@ public final class PeerInfoScreen: ViewController {
|
||||
), strings: baseNavigationBarPresentationData.strings))
|
||||
|
||||
if isSettings {
|
||||
let activeSessionsContextAndCountSignal = deferred { () -> Signal<(ActiveSessionsContext, Int, WebSessionsContext)?, NoError> in
|
||||
let activeSessionsContext = ActiveSessionsContext(account: context.account)
|
||||
let webSessionsContext = WebSessionsContext(account: context.account)
|
||||
let otherSessionCount = activeSessionsContext.state
|
||||
|> map { state -> Int in
|
||||
return state.sessions.filter({ !$0.isCurrent }).count
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
return otherSessionCount
|
||||
|> map { value in
|
||||
return (activeSessionsContext, value, webSessionsContext)
|
||||
}
|
||||
}
|
||||
self.activeSessionsContextAndCount.set(activeSessionsContextAndCountSignal)
|
||||
|
||||
self.accountsAndPeers.set(activeAccountsAndPeers(context: context))
|
||||
|
||||
self.accountsAndPeersDisposable = (self.accountsAndPeers.get()
|
||||
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||
self?.accountsAndPeersValue = value
|
||||
@ -5780,6 +5798,7 @@ public final class PeerInfoScreen: ViewController {
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = PeerInfoScreenNode(controller: self, context: self.context, peerId: self.peerId, avatarInitiallyExpanded: self.avatarInitiallyExpanded, isOpenedFromChat: self.isOpenedFromChat, nearbyPeerDistance: self.nearbyPeerDistance, callMessages: self.callMessages, isSettings: self.isSettings, ignoreGroupInCommon: self.ignoreGroupInCommon)
|
||||
self.controllerNode.accountsAndPeers.set(self.accountsAndPeers.get() |> map { $0.1 })
|
||||
self.controllerNode.activeSessionsContextAndCount.set(self.activeSessionsContextAndCount.get())
|
||||
self._ready.set(self.controllerNode.ready.get())
|
||||
|
||||
super.displayNodeDidLoad()
|
||||
|
Loading…
x
Reference in New Issue
Block a user