Various Fixes

This commit is contained in:
Ilya Laktyushin
2021-01-24 21:36:13 +03:00
parent bed5daf934
commit b1c8e8c640
7 changed files with 60 additions and 16 deletions

View File

@@ -306,6 +306,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
let historyNodeContainer: ASDisplayNode
let loadingNode: ChatLoadingNode
private var emptyNode: ChatEmptyNode?
private var emptyType: ChatHistoryNodeLoadState.EmptyType?
private var validEmptyNodeLayout: (CGSize, UIEdgeInsets)?
var restrictedNode: ChatRecentActionsEmptyNode?
@@ -535,11 +536,11 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
strongSelf.updateIsLoading(isLoading: false, animated: animated)
}
var isEmpty = false
if case .empty = loadState {
isEmpty = true
var emptyType: ChatHistoryNodeLoadState.EmptyType?
if case let .empty(type) = loadState {
emptyType = type
}
strongSelf.updateIsEmpty(isEmpty, animated: animated)
strongSelf.updateIsEmpty(emptyType, animated: animated)
}
}
@@ -707,11 +708,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
})
}
private func updateIsEmpty(_ isEmpty: Bool, animated: Bool) {
if isEmpty && self.emptyNode == nil {
private func updateIsEmpty(_ emptyType: ChatHistoryNodeLoadState.EmptyType?, animated: Bool) {
self.emptyType = emptyType
if let emptyType = emptyType, self.emptyNode == nil {
let emptyNode = ChatEmptyNode(account: self.context.account, interaction: self.interfaceInteraction)
if let (size, insets) = self.validEmptyNodeLayout {
emptyNode.updateLayout(interfaceState: self.chatPresentationInterfaceState, size: size, insets: insets, transition: .immediate)
emptyNode.updateLayout(interfaceState: self.chatPresentationInterfaceState, emptyType: emptyType, size: size, insets: insets, transition: .immediate)
}
emptyNode.isHidden = self.restrictedNode != nil
self.emptyNode = emptyNode
@@ -1374,8 +1376,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
var emptyNodeInsets = insets
emptyNodeInsets.bottom += inputPanelsHeight
self.validEmptyNodeLayout = (contentBounds.size, emptyNodeInsets)
if let emptyNode = self.emptyNode {
emptyNode.updateLayout(interfaceState: self.chatPresentationInterfaceState, size: contentBounds.size, insets: emptyNodeInsets, transition: transition)
if let emptyNode = self.emptyNode, let emptyType = self.emptyType {
emptyNode.updateLayout(interfaceState: self.chatPresentationInterfaceState, emptyType: emptyType, size: contentBounds.size, insets: emptyNodeInsets, transition: transition)
transition.updateFrame(node: emptyNode, frame: contentBounds)
}