no message

This commit is contained in:
Peter
2017-03-07 01:36:35 +03:00
parent c2578a0f97
commit be625d8f96
4 changed files with 101 additions and 1 deletions

23
.tx/config Normal file
View File

@@ -0,0 +1,23 @@
[main]
host = https://www.transifex.com
[iphone-1.descriptiontxt]
file_filter = translations/iphone-1.descriptiontxt/<lang>.txt
source_lang = en
type = TXT
[iphone-1.infopliststrings]
file_filter = translations/iphone-1.infopliststrings/<lang>.strings
source_lang = en
type = STRINGS
[iphone-1.localizablestrings_1]
file_filter = translations/iphone-1.localizablestrings_1/<lang>.strings
source_lang = en
type = STRINGS
[iphone-1.localizablestrings]
file_filter = translations/iphone-1.localizablestrings/<lang>.strings
source_lang = en
type = STRINGS

View File

@@ -23,6 +23,7 @@
D00C7CE91E379B820080C3D5 /* ChatSecretAutoremoveTimerActionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00C7CE81E379B820080C3D5 /* ChatSecretAutoremoveTimerActionSheet.swift */; };
D00C7CF71E37BF680080C3D5 /* SecretChatKeyVisualization.h in Headers */ = {isa = PBXBuildFile; fileRef = D00C7CF51E37BF680080C3D5 /* SecretChatKeyVisualization.h */; };
D00C7CF81E37BF680080C3D5 /* SecretChatKeyVisualization.m in Sources */ = {isa = PBXBuildFile; fileRef = D00C7CF61E37BF680080C3D5 /* SecretChatKeyVisualization.m */; };
D00D34371E6E14E30057B307 /* ChatMessageThrottledProcessingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00D34361E6E14E30057B307 /* ChatMessageThrottledProcessingManager.swift */; };
D00DBBDD1E65650800DB5485 /* ChatReportPeerTitlePanelNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00DBBDC1E65650800DB5485 /* ChatReportPeerTitlePanelNode.swift */; };
D00E15261DDBD4E700ACF65C /* LegacyCamera.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00E15251DDBD4E700ACF65C /* LegacyCamera.swift */; };
D0105D5A1D80B957008755D8 /* ChatChannelSubscriberInputPanelNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0105D591D80B957008755D8 /* ChatChannelSubscriberInputPanelNode.swift */; };
@@ -500,6 +501,7 @@
D00C7CE81E379B820080C3D5 /* ChatSecretAutoremoveTimerActionSheet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatSecretAutoremoveTimerActionSheet.swift; sourceTree = "<group>"; };
D00C7CF51E37BF680080C3D5 /* SecretChatKeyVisualization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecretChatKeyVisualization.h; sourceTree = "<group>"; };
D00C7CF61E37BF680080C3D5 /* SecretChatKeyVisualization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecretChatKeyVisualization.m; sourceTree = "<group>"; };
D00D34361E6E14E30057B307 /* ChatMessageThrottledProcessingManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageThrottledProcessingManager.swift; sourceTree = "<group>"; };
D00DBBDC1E65650800DB5485 /* ChatReportPeerTitlePanelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatReportPeerTitlePanelNode.swift; sourceTree = "<group>"; };
D00E15251DDBD4E700ACF65C /* LegacyCamera.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LegacyCamera.swift; sourceTree = "<group>"; };
D0105D591D80B957008755D8 /* ChatChannelSubscriberInputPanelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatChannelSubscriberInputPanelNode.swift; sourceTree = "<group>"; };
@@ -1754,6 +1756,7 @@
D0DE77261D932627002B8809 /* ChatHistoryNode.swift */,
D0E7A1BC1D8C246D00C37A6F /* ChatHistoryListNode.swift */,
D02BE0701D91814C000889C2 /* ChatHistoryGridNode.swift */,
D00D34361E6E14E30057B307 /* ChatMessageThrottledProcessingManager.swift */,
D0DE772C1D934DCB002B8809 /* List Items */,
D02BE0751D9190CD000889C2 /* Grid Items */,
);
@@ -2663,6 +2666,7 @@
D0528E631E65BECA00E2FEF5 /* UserInfoController.swift in Sources */,
D0F69E751D6B8C340046BCD6 /* ContactsPeerItem.swift in Sources */,
D01B27991E39144C0022A4C0 /* ItemListController.swift in Sources */,
D00D34371E6E14E30057B307 /* ChatMessageThrottledProcessingManager.swift in Sources */,
D0561DE11E57153000E6B9E9 /* ItemListActivityTextItem.swift in Sources */,
D0F69DD61D6B8A2D0046BCD6 /* AlertController.swift in Sources */,
D00370301DA43077004308D3 /* ItemListItem.swift in Sources */,

View File

@@ -210,6 +210,8 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
private let galleryHiddenMesageAndMediaDisposable = MetaDisposable()
private let messageProcessingManager = ChatMessageThrottledProcessingManager()
public init(account: Account, peerId: PeerId, tagMask: MessageTags?, messageId: MessageId?, controllerInteraction: ChatControllerInteraction, mode: ChatHistoryListMode = .bubbles) {
self.account = account
self.peerId = peerId
@@ -223,6 +225,10 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
//self.debugInfo = true
self.messageProcessingManager.process = { [weak account] messageIds in
account?.viewTracker.updatedViewCountMessageIds(messageIds: messageIds)
}
self.preloadPages = false
switch self.mode {
case .bubbles:
@@ -346,7 +352,25 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
if let strongSelf = self {
if let historyView = (opaqueTransactionState as? ChatHistoryTransactionOpaqueState)?.historyView {
if let visible = displayedRange.visibleRange {
if let messageIndex = maxIncomingMessageIndexForEntries(historyView.filteredEntries, indexRange: (historyView.filteredEntries.count - 1 - visible.lastIndex, historyView.filteredEntries.count - 1 - visible.firstIndex)) {
let indexRange = (historyView.filteredEntries.count - 1 - visible.lastIndex, historyView.filteredEntries.count - 1 - visible.firstIndex)
var messageIdsWithViewCount: [MessageId] = []
for i in (indexRange.0 ... indexRange.1) {
if case let .MessageEntry(message, _) = historyView.filteredEntries[i] {
inner: for attribute in message.attributes {
if attribute is ViewCountMessageAttribute {
messageIdsWithViewCount.append(message.id)
break inner
}
}
}
}
if !messageIdsWithViewCount.isEmpty {
strongSelf.messageProcessingManager.add(messageIdsWithViewCount)
}
if let messageIndex = maxIncomingMessageIndexForEntries(historyView.filteredEntries, indexRange: indexRange) {
strongSelf.updateMaxVisibleReadIncomingMessageIndex(messageIndex)
}
}

View File

@@ -0,0 +1,49 @@
import Foundation
import Postbox
import SwiftSignalKit
final class ChatMessageThrottledProcessingManager {
private let queue = Queue(target: Queue.concurrentBackgroundQueue())
var process: ((Set<MessageId>) -> Void)?
private var timer: SwiftSignalKit.Timer?
private var processed = Set<MessageId>()
private var buffer = Set<MessageId>()
func setProcess(process: @escaping (Set<MessageId>) -> Void) {
self.queue.async {
self.process = process
}
}
func add(_ messageIds: [MessageId]) {
self.queue.async {
for id in messageIds {
if !self.processed.contains(id) {
self.processed.insert(id)
self.buffer.insert(id)
}
}
if self.timer == nil {
var completionImpl: (() -> Void)?
let timer = SwiftSignalKit.Timer(timeout: 1.0, repeat: false, completion: {
completionImpl?()
}, queue: self.queue)
completionImpl = { [weak self, weak timer] in
if let strongSelf = self {
if let timer = timer, strongSelf.timer === timer {
strongSelf.timer = nil
}
let buffer = strongSelf.buffer
strongSelf.buffer.removeAll()
strongSelf.process?(buffer)
}
}
self.timer = timer
timer.start()
}
}
}
}