mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 13:38:21 +00:00
CreateChannelController: display errors
This commit is contained in:
parent
e0354979a4
commit
3a98bd9872
@ -628,8 +628,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
if let textInputNode = self.textInputNode, textInputNode.keyboardAppearance != keyboardAppearance, textInputNode.isFirstResponder() {
|
||||
textInputNode.resignFirstResponder()
|
||||
textInputNode.becomeFirstResponder()
|
||||
textInputNode.keyboardAppearance = keyboardAppearance
|
||||
}
|
||||
self.textInputNode?.keyboardAppearance = keyboardAppearance
|
||||
|
||||
self.textInputContainer.backgroundColor = interfaceState.theme.chat.inputPanel.inputBackgroundColor
|
||||
|
||||
@ -692,7 +692,6 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
}
|
||||
if self.currentPlaceholder != placeholder || themeUpdated {
|
||||
self.currentPlaceholder = placeholder
|
||||
let placeholderLayout = TextNode.asyncLayout(self.textPlaceholderNode)
|
||||
let baseFontSize = max(17.0, interfaceState.fontSize.baseDisplaySize)
|
||||
self.textPlaceholderNode.attributedText = NSAttributedString(string: placeholder, font: Font.regular(baseFontSize), textColor: interfaceState.theme.chat.inputPanel.inputPlaceholderColor)
|
||||
self.textInputNode?.textView.accessibilityHint = placeholder
|
||||
@ -967,7 +966,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
self.actionButtons.updateLayout(size: CGSize(width: 44.0, height: minimalHeight), transition: transition, interfaceState: presentationInterfaceState)
|
||||
}
|
||||
|
||||
if let mediaRecordingState = interfaceState.inputTextPanelState.mediaRecordingState {
|
||||
if let _ = interfaceState.inputTextPanelState.mediaRecordingState {
|
||||
let text: String = "Send"
|
||||
let mediaRecordingAccessibilityArea: AccessibilityAreaNode
|
||||
var added = false
|
||||
|
||||
@ -234,7 +234,9 @@ public func createChannelController(context: AccountContext) -> ViewController {
|
||||
}
|
||||
|
||||
endEditingImpl?()
|
||||
actionsDisposable.add((createChannel(account: context.account, title: title, description: description.isEmpty ? nil : description) |> deliverOnMainQueue |> afterDisposed {
|
||||
actionsDisposable.add((createChannel(account: context.account, title: title, description: description.isEmpty ? nil : description)
|
||||
|> deliverOnMainQueue
|
||||
|> afterDisposed {
|
||||
Queue.mainQueue().async {
|
||||
updateState { current in
|
||||
var current = current
|
||||
@ -243,21 +245,27 @@ public func createChannelController(context: AccountContext) -> ViewController {
|
||||
}
|
||||
}
|
||||
}).start(next: { peerId in
|
||||
if let peerId = peerId {
|
||||
let updatingAvatar = stateValue.with {
|
||||
return $0.avatar
|
||||
}
|
||||
if let _ = updatingAvatar {
|
||||
let _ = updatePeerPhoto(postbox: context.account.postbox, network: context.account.network, stateManager: context.account.stateManager, accountPeerId: context.account.peerId, peerId: peerId, photo: uploadedAvatar.get(), mapResourceToAvatarSizes: { resource, representations in
|
||||
return mapResourceToAvatarSizes(postbox: context.account.postbox, resource: resource, representations: representations)
|
||||
}).start()
|
||||
}
|
||||
|
||||
let controller = channelVisibilityController(context: context, peerId: peerId, mode: .initialSetup, upgradedToSupergroup: { _, f in f() })
|
||||
replaceControllerImpl?(controller)
|
||||
let updatingAvatar = stateValue.with {
|
||||
return $0.avatar
|
||||
}
|
||||
if let _ = updatingAvatar {
|
||||
let _ = updatePeerPhoto(postbox: context.account.postbox, network: context.account.network, stateManager: context.account.stateManager, accountPeerId: context.account.peerId, peerId: peerId, photo: uploadedAvatar.get(), mapResourceToAvatarSizes: { resource, representations in
|
||||
return mapResourceToAvatarSizes(postbox: context.account.postbox, resource: resource, representations: representations)
|
||||
}).start()
|
||||
}
|
||||
}, error: { _ in
|
||||
|
||||
let controller = channelVisibilityController(context: context, peerId: peerId, mode: .initialSetup, upgradedToSupergroup: { _, f in f() })
|
||||
replaceControllerImpl?(controller)
|
||||
}, error: { error in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let text: String
|
||||
switch error {
|
||||
case .generic:
|
||||
text = presentationData.strings.Login_UnknownError
|
||||
case .restricted:
|
||||
text = presentationData.strings.Common_ActionNotAllowedError
|
||||
}
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
}))
|
||||
}
|
||||
}, changeProfilePhoto: {
|
||||
|
||||
@ -261,7 +261,15 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
||||
let createSignal: Signal<PeerId?, CreateGroupError>
|
||||
if supergroup {
|
||||
createSignal = createSupergroup(account: context.account, title: title, description: nil)
|
||||
|> introduceError(CreateGroupError.self)
|
||||
|> map(Optional.init)
|
||||
|> mapError { error -> CreateGroupError in
|
||||
switch error {
|
||||
case .generic:
|
||||
return .generic
|
||||
case .restricted:
|
||||
return .restricted
|
||||
}
|
||||
}
|
||||
} else {
|
||||
createSignal = createGroup(account: context.account, title: title, peerIds: peerIds)
|
||||
}
|
||||
@ -318,6 +326,8 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelMultipleError
|
||||
case .generic:
|
||||
text = presentationData.strings.Login_UnknownError
|
||||
case .restricted:
|
||||
text = presentationData.strings.Common_ActionNotAllowedError
|
||||
}
|
||||
presentControllerImpl?(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
}))
|
||||
|
||||
@ -692,7 +692,8 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
updateState { current in
|
||||
peerIds = peerIds.union(current.mode.peerIds)
|
||||
let key: PostboxViewKey = .peerNotificationSettings(peerIds: peerIds)
|
||||
updateNotificationsDisposable.set((context.account.postbox.combinedView(keys: [key]) |> deliverOnMainQueue).start(next: { view in
|
||||
updateNotificationsDisposable.set((context.account.postbox.combinedView(keys: [key])
|
||||
|> deliverOnMainQueue).start(next: { view in
|
||||
if let view = view.views[key] as? PeerNotificationSettingsView {
|
||||
_ = context.account.postbox.transaction { transaction in
|
||||
updateState { current in
|
||||
@ -724,6 +725,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
updateNotificationsView({})
|
||||
|
||||
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
|
||||
var dismissInputImpl: (() -> Void)?
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.modify {$0}
|
||||
|
||||
@ -758,6 +760,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
return
|
||||
}
|
||||
|
||||
dismissInputImpl?()
|
||||
presentControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, mode: mode, updatePeerSound: { peerId, sound in
|
||||
_ = updatePeerSound(peer.id, sound).start(next: { _ in
|
||||
updateNotificationsDisposable.set(nil)
|
||||
@ -842,6 +845,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
controller?.dismiss()
|
||||
})
|
||||
}
|
||||
dismissInputImpl?()
|
||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}, updateRevealedPeerId: { peerId in
|
||||
updateState { current in
|
||||
@ -855,9 +859,14 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
} |> deliverOnMainQueue).start(completed: {
|
||||
updateNotificationsDisposable.set(nil)
|
||||
updateState { value in
|
||||
return value.withUpdatedPeerMuteInterval(peer, nil).withUpdatedPeerSound(peer, .default)
|
||||
return value.withUpdatedPeerMuteInterval(peer, nil).withUpdatedPeerSound(peer, .default).withUpdatedPeerDisplayPreviews(peer, .default)
|
||||
}
|
||||
_ = combineLatest(updatePeerSound(peer.id, .default), updatePeerNotificationInterval(peer.id, nil)).start(next: { _, _ in
|
||||
_ = (context.account.postbox.transaction { transaction in
|
||||
updatePeerNotificationSoundInteractive(transaction: transaction, peerId: peer.id, sound: .default)
|
||||
updatePeerMuteSetting(transaction: transaction, peerId: peer.id, muteInterval: nil)
|
||||
updatePeerDisplayPreviewsSetting(transaction: transaction, peerId: peer.id, displayPreviews: .default)
|
||||
}
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
updateNotificationsView({})
|
||||
})
|
||||
})
|
||||
@ -903,6 +912,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
actionSheet?.dismissAnimated()
|
||||
})
|
||||
])])
|
||||
dismissInputImpl?()
|
||||
presentControllerImpl?(actionSheet, nil)
|
||||
})
|
||||
|
||||
@ -912,6 +922,10 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
||||
self?.present(c, a)
|
||||
}
|
||||
|
||||
dismissInputImpl = { [weak self] in
|
||||
self?.view.endEditing(true)
|
||||
}
|
||||
|
||||
let preferences = context.account.postbox.preferencesView(keys: [PreferencesKeys.globalNotifications])
|
||||
|
||||
let previousEntriesHolder = Atomic<([NotificationExceptionEntry], PresentationTheme, PresentationStrings)?>(value: nil)
|
||||
|
||||
@ -11,6 +11,8 @@ public final class PeerSelectionController: ViewController {
|
||||
private var presentationData: PresentationData
|
||||
private var presentationDataDisposable: Disposable?
|
||||
|
||||
private var customTitle: String?
|
||||
|
||||
var peerSelected: ((PeerId) -> Void)?
|
||||
private let filter: ChatListNodePeersFilter
|
||||
|
||||
@ -54,7 +56,8 @@ public final class PeerSelectionController: ViewController {
|
||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
||||
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
||||
|
||||
self.title = title ?? self.presentationData.strings.Conversation_ForwardTitle
|
||||
self.customTitle = title
|
||||
self.title = self.customTitle ?? self.presentationData.strings.Conversation_ForwardTitle
|
||||
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
||||
|
||||
@ -100,7 +103,7 @@ public final class PeerSelectionController: ViewController {
|
||||
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
||||
self.navigationBar?.updatePresentationData(NavigationBarPresentationData(presentationData: self.presentationData))
|
||||
self.searchContentNode?.updateThemeAndPlaceholder(theme: self.presentationData.theme, placeholder: self.presentationData.strings.Common_Search)
|
||||
self.title = self.presentationData.strings.Conversation_ForwardTitle
|
||||
self.title = self.customTitle ?? self.presentationData.strings.Conversation_ForwardTitle
|
||||
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user