Add "group is full" error

This commit is contained in:
Ilya Laktyushin 2021-02-22 20:22:32 +04:00
parent da1c02c0a2
commit b8c06ddffe
7 changed files with 2540 additions and 2522 deletions

View File

@ -6149,3 +6149,5 @@ Sorry for the inconvenience.";
"Channel.Setup.LinkTypePrivate" = "Private";
"VoiceOver.ScrollStatus" = "Row %1$@ of %2$@";
"Conversation.UsersTooMuchError" = "Sorry, this group is full.";

View File

@ -128,22 +128,27 @@ public final class JoinLinkPreviewController: ViewController {
}
}, error: { [weak self] error in
if let strongSelf = self {
if case .tooMuchJoined = error {
if let parentNavigationController = strongSelf.parentNavigationController {
let context = strongSelf.context
let link = strongSelf.link
let navigateToPeer = strongSelf.navigateToPeer
let resolvedState = strongSelf.resolvedState
parentNavigationController.pushViewController(oldChannelsController(context: strongSelf.context, intent: .join, completed: { [weak parentNavigationController] value in
if value {
(parentNavigationController?.viewControllers.last as? ViewController)?.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: navigateToPeer, parentNavigationController: parentNavigationController, resolvedState: resolvedState), in: .window(.root))
}
}))
} else {
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()
switch error {
case .tooMuchJoined:
if let parentNavigationController = strongSelf.parentNavigationController {
let context = strongSelf.context
let link = strongSelf.link
let navigateToPeer = strongSelf.navigateToPeer
let resolvedState = strongSelf.resolvedState
parentNavigationController.pushViewController(oldChannelsController(context: strongSelf.context, intent: .join, completed: { [weak parentNavigationController] value in
if value {
(parentNavigationController?.viewControllers.last as? ViewController)?.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: navigateToPeer, parentNavigationController: parentNavigationController, resolvedState: resolvedState), in: .window(.root))
}
}))
} else {
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))
}
case .tooMuchUsers:
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Conversation_UsersTooMuchError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
case .generic:
break
}
strongSelf.dismiss()
}
}))
}

View File

@ -8,6 +8,7 @@ import SyncCore
public enum JoinChannelError {
case generic
case tooMuchJoined
case tooMuchUsers
}
public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChannelParticipant?, JoinChannelError> {
@ -18,10 +19,13 @@ public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChan
if let inputChannel = apiInputChannel(peer) {
return account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
|> mapError { error -> JoinChannelError in
if error.errorDescription == "CHANNELS_TOO_MUCH" {
return .tooMuchJoined
} else {
return .generic
switch error.errorDescription {
case "CHANNELS_TOO_MUCH":
return .tooMuchJoined
case "USERS_TOO_MUCH":
return .tooMuchUsers
default:
return .generic
}
}
|> mapToSignal { updates -> Signal<RenderedChannelParticipant?, JoinChannelError> in

View File

@ -8,6 +8,7 @@ import SyncCore
public enum JoinLinkError {
case generic
case tooMuchJoined
case tooMuchUsers
}
func apiUpdatesGroups(_ updates: Api.Updates) -> [Api.Chat] {
@ -31,10 +32,13 @@ public enum ExternalJoiningChatState {
public func joinChatInteractively(with hash: String, account: Account) -> Signal <PeerId?, JoinLinkError> {
return account.network.request(Api.functions.messages.importChatInvite(hash: hash))
|> mapError { error -> JoinLinkError in
if error.errorDescription == "CHANNELS_TOO_MUCH" {
return .tooMuchJoined
} else {
return .generic
switch error.errorDescription {
case "CHANNELS_TOO_MUCH":
return .tooMuchJoined
case "USERS_TOO_MUCH":
return .tooMuchUsers
default:
return .generic
}
}
|> mapToSignal { updates -> Signal<PeerId?, JoinLinkError> in

View File

@ -189,7 +189,9 @@ final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
}
}))
return
default:
case .tooMuchUsers:
text = presentationInterfaceState.strings.Conversation_UsersTooMuchError
case .generic:
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
text = presentationInterfaceState.strings.Channel_ErrorAccessDenied
} else {