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"; "Channel.Setup.LinkTypePrivate" = "Private";
"VoiceOver.ScrollStatus" = "Row %1$@ of %2$@"; "VoiceOver.ScrollStatus" = "Row %1$@ of %2$@";
"Conversation.UsersTooMuchError" = "Sorry, this group is full.";

View File

@ -128,7 +128,8 @@ public final class JoinLinkPreviewController: ViewController {
} }
}, error: { [weak self] error in }, error: { [weak self] error in
if let strongSelf = self { if let strongSelf = self {
if case .tooMuchJoined = error { switch error {
case .tooMuchJoined:
if let parentNavigationController = strongSelf.parentNavigationController { if let parentNavigationController = strongSelf.parentNavigationController {
let context = strongSelf.context let context = strongSelf.context
let link = strongSelf.link let link = strongSelf.link
@ -142,8 +143,12 @@ public final class JoinLinkPreviewController: ViewController {
} else { } 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.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() 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 { public enum JoinChannelError {
case generic case generic
case tooMuchJoined case tooMuchJoined
case tooMuchUsers
} }
public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChannelParticipant?, JoinChannelError> { public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChannelParticipant?, JoinChannelError> {
@ -18,9 +19,12 @@ public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChan
if let inputChannel = apiInputChannel(peer) { if let inputChannel = apiInputChannel(peer) {
return account.network.request(Api.functions.channels.joinChannel(channel: inputChannel)) return account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
|> mapError { error -> JoinChannelError in |> mapError { error -> JoinChannelError in
if error.errorDescription == "CHANNELS_TOO_MUCH" { switch error.errorDescription {
case "CHANNELS_TOO_MUCH":
return .tooMuchJoined return .tooMuchJoined
} else { case "USERS_TOO_MUCH":
return .tooMuchUsers
default:
return .generic return .generic
} }
} }

View File

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

View File

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