mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-25 20:50:47 +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 adminsTooMuch
|
||||||
case userPublicChannelsTooMuch
|
case userPublicChannelsTooMuch
|
||||||
case userLocatedGroupsTooMuch
|
case userLocatedGroupsTooMuch
|
||||||
|
case tooMuchJoined
|
||||||
case restricted
|
case restricted
|
||||||
case userBlocked
|
case userBlocked
|
||||||
}
|
}
|
||||||
@ -64,6 +65,8 @@ public func checkOwnershipTranfserAvailability(postbox: Postbox, network: Networ
|
|||||||
return .restricted
|
return .restricted
|
||||||
} else if error.errorDescription == "USER_BLOCKED" {
|
} else if error.errorDescription == "USER_BLOCKED" {
|
||||||
return .userBlocked
|
return .userBlocked
|
||||||
|
} else if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||||
|
return .tooMuchJoined
|
||||||
}
|
}
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public enum JoinLinkError {
|
||||||
|
case generic
|
||||||
|
case tooMuchJoined
|
||||||
|
}
|
||||||
|
|
||||||
func apiUpdatesGroups(_ updates: Api.Updates) -> [Api.Chat] {
|
func apiUpdatesGroups(_ updates: Api.Updates) -> [Api.Chat] {
|
||||||
switch updates {
|
switch updates {
|
||||||
case let .updates( _, _, chats, _, _):
|
case let .updates( _, _, chats, _, _):
|
||||||
@ -31,31 +36,31 @@ public enum ExternalJoiningChatState {
|
|||||||
case invalidHash
|
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))
|
return account.network.request(Api.functions.messages.importChatInvite(hash: hash))
|
||||||
|> map(Optional.init)
|
|> mapError { error -> JoinLinkError in
|
||||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||||
return .single(nil)
|
return .tooMuchJoined
|
||||||
}
|
|
||||||
|> 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)
|
|
||||||
} else {
|
} 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> {
|
public func joinLinkInformation(_ hash: String, account: Account) -> Signal<ExternalJoiningChatState, NoError> {
|
||||||
|
@ -105,6 +105,13 @@ public final class JoinLinkPreviewController: ViewController {
|
|||||||
strongSelf.dismiss()
|
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 let separatorNode: ASDisplayNode
|
||||||
|
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
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) {
|
init(accountPeerId: PeerId, theme: PresentationTheme, strings: PresentationStrings, tapAction: @escaping () -> Void, close: @escaping () -> Void) {
|
||||||
self.accountPeerId = accountPeerId
|
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)
|
let titleString = NSAttributedString(string: self.strings.Conversation_LiveLocation, font: titleFont, textColor: self.theme.rootController.navigationBar.primaryTextColor)
|
||||||
var subtitleString: NSAttributedString?
|
var subtitleString: NSAttributedString?
|
||||||
if let (peers, mode) = self.peersAndMode {
|
if let (peers, mode, canClose) = self.peersAndMode {
|
||||||
switch mode {
|
switch mode {
|
||||||
case .summary:
|
case .summary:
|
||||||
let text: String
|
let text: String
|
||||||
@ -119,6 +119,7 @@ final class LocationBroadcastNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
subtitleString = NSAttributedString(string: text, font: subtitleFont, textColor: self.theme.rootController.navigationBar.secondaryTextColor)
|
subtitleString = NSAttributedString(string: text, font: subtitleFont, textColor: self.theme.rootController.navigationBar.secondaryTextColor)
|
||||||
case .peer:
|
case .peer:
|
||||||
|
self.closeButton.isHidden = !canClose
|
||||||
let filteredPeers = peers.filter {
|
let filteredPeers = peers.filter {
|
||||||
$0.id != self.accountPeerId
|
$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)))
|
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) {
|
func update(peers: [Peer], mode: LocationBroadcastNavigationAccessoryPanelMode, canClose: Bool) {
|
||||||
self.peersAndMode = (peers, mode)
|
self.peersAndMode = (peers, mode, canClose)
|
||||||
if let layout = validLayout {
|
if let layout = validLayout {
|
||||||
self.updateLayout(size: layout.0, leftInset: layout.1, rightInset: layout.2, transition: .immediate)
|
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)
|
peers?.append(author)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (peers, nil)
|
return (peers, outgoingMessages)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
self.locationBroadcastMode = .summary
|
self.locationBroadcastMode = .summary
|
||||||
signal = liveLocationManager.summaryManager.broadcastingToMessages()
|
signal = liveLocationManager.summaryManager.broadcastingToMessages()
|
||||||
|> map { messages -> ([Peer]?, [MessageId: Message]?) in
|
|> map { messages -> ([Peer]?, [MessageId: Message]?) in
|
||||||
if messages.isEmpty {
|
if messages.isEmpty {
|
||||||
return (nil, nil)
|
return (nil, nil)
|
||||||
} else {
|
} else {
|
||||||
var peers: [Peer] = []
|
var peers: [Peer] = []
|
||||||
for message in messages.values.sorted(by: { $0.index < $1.index }) {
|
for message in messages.values.sorted(by: { $0.index < $1.index }) {
|
||||||
if let peer = message.peers[message.id.peerId] {
|
if let peer = message.peers[message.id.peerId] {
|
||||||
peers.append(peer)
|
peers.append(peer)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (peers, messages)
|
|
||||||
}
|
}
|
||||||
|
return (peers, messages)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,16 @@ public class TelegramController: ViewController, KeyShortcutResponder {
|
|||||||
if wasEmpty != (peers == nil) {
|
if wasEmpty != (peers == nil) {
|
||||||
strongSelf.requestLayout(transition: .animated(duration: 0.4, curve: .spring))
|
strongSelf.requestLayout(transition: .animated(duration: 0.4, curve: .spring))
|
||||||
} else if let peers = peers, let locationBroadcastMode = strongSelf.locationBroadcastMode {
|
} 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
|
self.locationBroadcastAccessoryPanel = locationBroadcastAccessoryPanel
|
||||||
locationBroadcastAccessoryPanel.frame = panelFrame
|
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)
|
locationBroadcastAccessoryPanel.updateLayout(size: panelFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: .immediate)
|
||||||
if transition.isAnimated {
|
if transition.isAnimated {
|
||||||
locationBroadcastAccessoryPanel.animateIn(transition)
|
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)
|
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)
|
let targetScale = max(transformedFrame.size.width / videoNode.layer.bounds.size.width, transformedFrame.size.height / videoNode.layer.bounds.size.height)
|
||||||
|
|
||||||
videoNode.backgroundColor = .clear
|
videoNode.backgroundColor = .clear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user