mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-24 12:10:49 +00:00
More CHANNELS_TOO_MUCH errors support
Fixed gallery transition out for gifs in Instant View Don't display close button in live location panel in chats if not sharing own location
This commit is contained in:
parent
f4c63f22df
commit
4bc333bfdf
@ -21,6 +21,7 @@ public enum ChannelOwnershipTransferError {
|
||||
case adminsTooMuch
|
||||
case userPublicChannelsTooMuch
|
||||
case userLocatedGroupsTooMuch
|
||||
case tooMuchJoined
|
||||
case restricted
|
||||
case userBlocked
|
||||
}
|
||||
@ -64,6 +65,8 @@ public func checkOwnershipTranfserAvailability(postbox: Postbox, network: Networ
|
||||
return .restricted
|
||||
} else if error.errorDescription == "USER_BLOCKED" {
|
||||
return .userBlocked
|
||||
} else if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||
return .tooMuchJoined
|
||||
}
|
||||
return .generic
|
||||
}
|
||||
|
@ -14,6 +14,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public enum JoinLinkError {
|
||||
case generic
|
||||
case tooMuchJoined
|
||||
}
|
||||
|
||||
func apiUpdatesGroups(_ updates: Api.Updates) -> [Api.Chat] {
|
||||
switch updates {
|
||||
case let .updates( _, _, chats, _, _):
|
||||
@ -31,31 +36,31 @@ public enum ExternalJoiningChatState {
|
||||
case invalidHash
|
||||
}
|
||||
|
||||
public func joinChatInteractively(with hash: String, account: Account) -> Signal <PeerId?, NoError> {
|
||||
public func joinChatInteractively(with hash: String, account: Account) -> Signal <PeerId?, JoinLinkError> {
|
||||
return account.network.request(Api.functions.messages.importChatInvite(hash: hash))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<PeerId?, NoError> in
|
||||
if let updates = updates {
|
||||
account.stateManager.addUpdates(updates)
|
||||
if let peerId = apiUpdatesGroups(updates).first?.peerId {
|
||||
return account.postbox.multiplePeersView([peerId])
|
||||
|> filter { view in
|
||||
return view.peers[peerId] != nil
|
||||
}
|
||||
|> take(1)
|
||||
|> map { _ in
|
||||
return peerId
|
||||
}
|
||||
|> timeout(5.0, queue: Queue.concurrentDefaultQueue(), alternate: .single(nil))
|
||||
}
|
||||
return .single(nil)
|
||||
|> mapError { error -> JoinLinkError in
|
||||
if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||
return .tooMuchJoined
|
||||
} else {
|
||||
return .single(nil)
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<PeerId?, JoinLinkError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
if let peerId = apiUpdatesGroups(updates).first?.peerId {
|
||||
return account.postbox.multiplePeersView([peerId])
|
||||
|> introduceError(JoinLinkError.self)
|
||||
|> filter { view in
|
||||
return view.peers[peerId] != nil
|
||||
}
|
||||
|> take(1)
|
||||
|> map { _ in
|
||||
return peerId
|
||||
}
|
||||
|> timeout(5.0, queue: Queue.concurrentDefaultQueue(), alternate: .single(nil) |> introduceError(JoinLinkError.self))
|
||||
}
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
|
||||
public func joinLinkInformation(_ hash: String, account: Account) -> Signal<ExternalJoiningChatState, NoError> {
|
||||
|
@ -105,6 +105,13 @@ public final class JoinLinkPreviewController: ViewController {
|
||||
strongSelf.dismiss()
|
||||
}
|
||||
}
|
||||
}, error: { [weak self] error in
|
||||
if let strongSelf = self {
|
||||
if case .tooMuchJoined = error {
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Join_ChannelsTooMuch, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
strongSelf.dismiss()
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ final class LocationBroadcastNavigationAccessoryPanel: ASDisplayNode {
|
||||
private let separatorNode: ASDisplayNode
|
||||
|
||||
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
||||
private var peersAndMode: ([Peer], LocationBroadcastNavigationAccessoryPanelMode)?
|
||||
private var peersAndMode: ([Peer], LocationBroadcastNavigationAccessoryPanelMode, Bool)?
|
||||
|
||||
init(accountPeerId: PeerId, theme: PresentationTheme, strings: PresentationStrings, tapAction: @escaping () -> Void, close: @escaping () -> Void) {
|
||||
self.accountPeerId = accountPeerId
|
||||
@ -108,7 +108,7 @@ final class LocationBroadcastNavigationAccessoryPanel: ASDisplayNode {
|
||||
|
||||
let titleString = NSAttributedString(string: self.strings.Conversation_LiveLocation, font: titleFont, textColor: self.theme.rootController.navigationBar.primaryTextColor)
|
||||
var subtitleString: NSAttributedString?
|
||||
if let (peers, mode) = self.peersAndMode {
|
||||
if let (peers, mode, canClose) = self.peersAndMode {
|
||||
switch mode {
|
||||
case .summary:
|
||||
let text: String
|
||||
@ -119,6 +119,7 @@ final class LocationBroadcastNavigationAccessoryPanel: ASDisplayNode {
|
||||
}
|
||||
subtitleString = NSAttributedString(string: text, font: subtitleFont, textColor: self.theme.rootController.navigationBar.secondaryTextColor)
|
||||
case .peer:
|
||||
self.closeButton.isHidden = !canClose
|
||||
let filteredPeers = peers.filter {
|
||||
$0.id != self.accountPeerId
|
||||
}
|
||||
@ -172,8 +173,8 @@ final class LocationBroadcastNavigationAccessoryPanel: ASDisplayNode {
|
||||
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: size.height - UIScreenPixel), size: CGSize(width: size.width, height: UIScreenPixel)))
|
||||
}
|
||||
|
||||
func update(peers: [Peer], mode: LocationBroadcastNavigationAccessoryPanelMode) {
|
||||
self.peersAndMode = (peers, mode)
|
||||
func update(peers: [Peer], mode: LocationBroadcastNavigationAccessoryPanelMode, canClose: Bool) {
|
||||
self.peersAndMode = (peers, mode, canClose)
|
||||
if let layout = validLayout {
|
||||
self.updateLayout(size: layout.0, leftInset: layout.1, rightInset: layout.2, transition: .immediate)
|
||||
}
|
||||
|
@ -184,24 +184,24 @@ public class TelegramController: ViewController, KeyShortcutResponder {
|
||||
peers?.append(author)
|
||||
}
|
||||
}
|
||||
return (peers, nil)
|
||||
return (peers, outgoingMessages)
|
||||
}
|
||||
default:
|
||||
self.locationBroadcastMode = .summary
|
||||
signal = liveLocationManager.summaryManager.broadcastingToMessages()
|
||||
|> map { messages -> ([Peer]?, [MessageId: Message]?) in
|
||||
if messages.isEmpty {
|
||||
return (nil, nil)
|
||||
} else {
|
||||
var peers: [Peer] = []
|
||||
for message in messages.values.sorted(by: { $0.index < $1.index }) {
|
||||
if let peer = message.peers[message.id.peerId] {
|
||||
peers.append(peer)
|
||||
}
|
||||
|> map { messages -> ([Peer]?, [MessageId: Message]?) in
|
||||
if messages.isEmpty {
|
||||
return (nil, nil)
|
||||
} else {
|
||||
var peers: [Peer] = []
|
||||
for message in messages.values.sorted(by: { $0.index < $1.index }) {
|
||||
if let peer = message.peers[message.id.peerId] {
|
||||
peers.append(peer)
|
||||
}
|
||||
return (peers, messages)
|
||||
}
|
||||
return (peers, messages)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -223,7 +223,16 @@ public class TelegramController: ViewController, KeyShortcutResponder {
|
||||
if wasEmpty != (peers == nil) {
|
||||
strongSelf.requestLayout(transition: .animated(duration: 0.4, curve: .spring))
|
||||
} else if let peers = peers, let locationBroadcastMode = strongSelf.locationBroadcastMode {
|
||||
strongSelf.locationBroadcastAccessoryPanel?.update(peers: peers, mode: locationBroadcastMode)
|
||||
var canClose = true
|
||||
if case let .peer(peerId) = strongSelf.locationBroadcastPanelSource, let messages = messages {
|
||||
canClose = false
|
||||
for messageId in messages.keys {
|
||||
if messageId.peerId == peerId {
|
||||
canClose = true
|
||||
}
|
||||
}
|
||||
}
|
||||
strongSelf.locationBroadcastAccessoryPanel?.update(peers: peers, mode: locationBroadcastMode, canClose: canClose)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,7 +410,18 @@ public class TelegramController: ViewController, KeyShortcutResponder {
|
||||
}
|
||||
self.locationBroadcastAccessoryPanel = locationBroadcastAccessoryPanel
|
||||
locationBroadcastAccessoryPanel.frame = panelFrame
|
||||
locationBroadcastAccessoryPanel.update(peers: locationBroadcastPeers, mode: locationBroadcastMode)
|
||||
|
||||
var canClose = true
|
||||
if case let .peer(peerId) = self.locationBroadcastPanelSource, let messages = self.locationBroadcastMessages {
|
||||
canClose = false
|
||||
for messageId in messages.keys {
|
||||
if messageId.peerId == peerId {
|
||||
canClose = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
locationBroadcastAccessoryPanel.update(peers: locationBroadcastPeers, mode: locationBroadcastMode, canClose: canClose)
|
||||
locationBroadcastAccessoryPanel.updateLayout(size: panelFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: .immediate)
|
||||
if transition.isAnimated {
|
||||
locationBroadcastAccessoryPanel.animateIn(transition)
|
||||
|
@ -890,7 +890,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
transformedSuperFrame = transformedSuperFrame.offsetBy(dx: videoNode.position.x - previousFrame.center.x, dy: videoNode.position.y - previousFrame.center.y)
|
||||
}
|
||||
|
||||
let initialScale = min(videoNode.layer.bounds.width / node.0.view.bounds.width, videoNode.layer.bounds.height / node.0.view.bounds.height)
|
||||
let initialScale: CGFloat = 1.0 //min(videoNode.layer.bounds.width / node.0.view.bounds.width, videoNode.layer.bounds.height / node.0.view.bounds.height)
|
||||
let targetScale = max(transformedFrame.size.width / videoNode.layer.bounds.size.width, transformedFrame.size.height / videoNode.layer.bounds.size.height)
|
||||
|
||||
videoNode.backgroundColor = .clear
|
||||
|
Loading…
x
Reference in New Issue
Block a user