mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Web app improvements
This commit is contained in:
@@ -97,7 +97,8 @@ public class AttachmentController: ViewController {
|
||||
private let context: AccountContext
|
||||
private let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?
|
||||
private let chatLocation: ChatLocation
|
||||
private var buttons: [AttachmentButtonType]
|
||||
private let buttons: [AttachmentButtonType]
|
||||
private let initialButton: AttachmentButtonType
|
||||
|
||||
public var mediaPickerContext: AttachmentMediaPickerContext? {
|
||||
get {
|
||||
@@ -268,7 +269,20 @@ public class AttachmentController: ViewController {
|
||||
|
||||
self.dim.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
|
||||
|
||||
let _ = self.switchToController(.gallery)
|
||||
if let controller = self.controller {
|
||||
let _ = self.switchToController(controller.initialButton)
|
||||
if case let .app(botId, _, _) = controller.initialButton {
|
||||
if let index = controller.buttons.firstIndex(where: {
|
||||
if case let .app(otherBotId, _, _) = $0, otherBotId == botId {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}) {
|
||||
self.panel.updateSelectedIndex(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateSelectionCount(_ count: Int) {
|
||||
@@ -293,25 +307,6 @@ public class AttachmentController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
func switchTo(_ type: AttachmentButtonType) {
|
||||
guard let buttons = self.controller?.buttons else {
|
||||
return
|
||||
}
|
||||
if case let .app(botId, _, _) = type {
|
||||
let index = buttons.firstIndex(where: {
|
||||
if case let .app(otherBotId, _, _) = $0, otherBotId == botId {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
if let index = index {
|
||||
self.panel.updateSelectedIndex(index)
|
||||
let _ = self.switchToController(buttons[index], animated: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func switchToController(_ type: AttachmentButtonType, animated: Bool = true) -> Bool {
|
||||
guard self.currentType != type else {
|
||||
if self.animating {
|
||||
@@ -583,13 +578,12 @@ public class AttachmentController: ViewController {
|
||||
completion(nil, nil)
|
||||
}
|
||||
|
||||
private var buttonsDisposable: Disposable?
|
||||
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, chatLocation: ChatLocation, buttons: Signal<[AttachmentButtonType], NoError>) {
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, chatLocation: ChatLocation, buttons: [AttachmentButtonType], initialButton: AttachmentButtonType = .gallery) {
|
||||
self.context = context
|
||||
self.updatedPresentationData = updatedPresentationData
|
||||
self.chatLocation = chatLocation
|
||||
self.buttons = []
|
||||
self.buttons = buttons
|
||||
self.initialButton = initialButton
|
||||
|
||||
super.init(navigationBarPresentationData: nil)
|
||||
|
||||
@@ -602,21 +596,6 @@ public class AttachmentController: ViewController {
|
||||
strongSelf.node.scrollToTop()
|
||||
}
|
||||
}
|
||||
|
||||
self.buttonsDisposable = (buttons
|
||||
|> deliverOnMainQueue).start(next: { [weak self] buttons in
|
||||
if let strongSelf = self {
|
||||
let previousButtons = strongSelf.buttons
|
||||
strongSelf.buttons = buttons
|
||||
if let layout = strongSelf.validLayout {
|
||||
strongSelf.containerLayoutUpdated(layout, transition: !previousButtons.isEmpty ? .animated(duration: 0.2, curve: .easeInOut) : .immediate)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.buttonsDisposable?.dispose()
|
||||
}
|
||||
|
||||
public required init(coder aDecoder: NSCoder) {
|
||||
@@ -632,10 +611,6 @@ public class AttachmentController: ViewController {
|
||||
self.displayNodeDidLoad()
|
||||
}
|
||||
|
||||
public func switchTo(_ type: AttachmentButtonType) {
|
||||
(self.displayNode as! Node).switchTo(type)
|
||||
}
|
||||
|
||||
public func _dismiss() {
|
||||
super.dismiss(animated: false, completion: {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user