mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update read mechanic
This commit is contained in:
parent
743551096f
commit
d2ffa8e19e
@ -380,7 +380,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
||||
|
||||
private final class AdaptedCallVideoSource: VideoSource {
|
||||
private static let queue = Queue(name: "AdaptedCallVideoSource")
|
||||
var updated: (() -> Void)?
|
||||
private var onUpdatedListeners = Bag<() -> Void>()
|
||||
private(set) var currentOutput: Output?
|
||||
|
||||
private var textureCache: CVMetalTextureCache?
|
||||
@ -425,7 +425,7 @@ private final class AdaptedCallVideoSource: VideoSource {
|
||||
return
|
||||
}
|
||||
|
||||
output = Output(y: yTexture, uv: uvTexture, rotationAngle: rotationAngle, sourceId: videoFrameData.mirrorHorizontally || videoFrameData.mirrorVertically ? 1 : 0)
|
||||
output = Output(resolution: CGSize(width: CGFloat(yTexture.width), height: CGFloat(yTexture.height)), y: yTexture, uv: uvTexture, rotationAngle: rotationAngle, sourceId: videoFrameData.mirrorHorizontally || videoFrameData.mirrorVertically ? 1 : 0)
|
||||
default:
|
||||
return
|
||||
}
|
||||
@ -435,12 +435,27 @@ private final class AdaptedCallVideoSource: VideoSource {
|
||||
return
|
||||
}
|
||||
self.currentOutput = output
|
||||
self.updated?()
|
||||
for onUpdated in self.onUpdatedListeners.copyItems() {
|
||||
onUpdated()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func addOnUpdated(_ f: @escaping () -> Void) -> Disposable {
|
||||
let index = self.onUpdatedListeners.add(f)
|
||||
|
||||
return ActionDisposable { [weak self] in
|
||||
DispatchQueue.main.async {
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.onUpdatedListeners.remove(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.videoFrameDisposable?.dispose()
|
||||
}
|
||||
|
@ -893,6 +893,35 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
|
||||
strongSelf.maybeUpdateOverscrollAction(offset: offsetFromBottom)
|
||||
}
|
||||
|
||||
var maxMessage: Message?
|
||||
strongSelf.forEachVisibleMessageItemNode { itemNode in
|
||||
if let item = itemNode.item {
|
||||
var matches = false
|
||||
if itemNode.frame.maxY < strongSelf.insets.top {
|
||||
return
|
||||
}
|
||||
if itemNode.frame.minY >= strongSelf.insets.top {
|
||||
matches = true
|
||||
} else if itemNode.frame.minY >= strongSelf.insets.top - 100.0 {
|
||||
matches = true
|
||||
}
|
||||
|
||||
if matches {
|
||||
if let maxMessageValue = maxMessage {
|
||||
if maxMessageValue.index < item.message.index {
|
||||
maxMessage = item.message
|
||||
}
|
||||
} else {
|
||||
maxMessage = item.message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let maxMessage {
|
||||
//print("read \(maxMessage.text)")
|
||||
strongSelf.updateMaxVisibleReadIncomingMessageIndex(maxMessage.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3234,7 +3263,8 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
}
|
||||
|
||||
if let messageIndex = messageIndex {
|
||||
strongSelf.updateMaxVisibleReadIncomingMessageIndex(messageIndex)
|
||||
let _ = messageIndex
|
||||
//strongSelf.updateMaxVisibleReadIncomingMessageIndex(messageIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user