mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-04 10:30:42 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
1bcce98c49
@ -104,9 +104,8 @@
|
||||
"PUSH_MESSAGES_1" = "%1$@|sent you a message";
|
||||
"PUSH_MESSAGES_any" = "%1$@|sent you %2$d messages";
|
||||
"PUSH_ALBUM" = "%1$@|sent you an album";
|
||||
"PUSH_MESSAGE_DOCS" = "%1$@|sent you %2$d files";
|
||||
"PUSH_MESSAGE_DOCS_1" = "%1$@|sent you a file";
|
||||
"PUSH_MESSAGE_DOCS_any" = "%1$@|sent you %2$d files";
|
||||
"PUSH_MESSAGE_FILES_1" = "%1$@|sent you a file";
|
||||
"PUSH_MESSAGE_FILES_any" = "%1$@|sent you %2$d files";
|
||||
|
||||
|
||||
"PUSH_CHANNEL_MESSAGE_TEXT" = "%1$@|%2$@";
|
||||
|
@ -348,7 +348,7 @@ final class MutableGlobalMessageTagsView: MutablePostboxView {
|
||||
}
|
||||
|
||||
if let later = self.later {
|
||||
addedEntries += postbox.messageHistoryTable.laterEntries(globalTagMask: self.globalTag, index: later.predecessor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
addedEntries += postbox.messageHistoryTable.laterEntries(globalTagMask: self.globalTag, index: later.globalPredecessor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
switch entry {
|
||||
case let .message(message):
|
||||
return .intermediateMessage(message)
|
||||
@ -358,7 +358,7 @@ final class MutableGlobalMessageTagsView: MutablePostboxView {
|
||||
}
|
||||
}
|
||||
if let earlier = self.earlier {
|
||||
addedEntries += postbox.messageHistoryTable.earlierEntries(globalTagMask: self.globalTag, index: earlier.successor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
addedEntries += postbox.messageHistoryTable.earlierEntries(globalTagMask: self.globalTag, index: earlier.globalSuccessor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
switch entry {
|
||||
case let .message(message):
|
||||
return .intermediateMessage(message)
|
||||
|
@ -103,12 +103,24 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
self.timestamp = timestamp
|
||||
}
|
||||
|
||||
public func predecessor() -> MessageIndex {
|
||||
public func globalPredecessor() -> MessageIndex {
|
||||
let previousPeerId = self.id.peerId.predecessor
|
||||
if previousPeerId != self.id.peerId {
|
||||
return MessageIndex(id: MessageId(peerId: previousPeerId, namespace: self.id.namespace, id: self.id.id), timestamp: self.timestamp)
|
||||
} else if self.id.id != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id), timestamp: self.timestamp)
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id - 1), timestamp: self.timestamp)
|
||||
} else if self.id.namespace != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace - 1, id: Int32.max - 1), timestamp: self.timestamp)
|
||||
} else if self.timestamp != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: Int32(Int8.max) - 1, id: Int32.max - 1), timestamp: self.timestamp - 1)
|
||||
} else {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
public func peerLocalPredecessor() -> MessageIndex {
|
||||
if self.id.id != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id - 1), timestamp: self.timestamp)
|
||||
} else if self.id.namespace != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace - 1, id: Int32.max - 1), timestamp: self.timestamp)
|
||||
} else if self.timestamp != 0 {
|
||||
@ -118,7 +130,7 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public func successor() -> MessageIndex {
|
||||
public func globalSuccessor() -> MessageIndex {
|
||||
let nextPeerId = self.id.peerId.successor
|
||||
if nextPeerId != self.id.peerId {
|
||||
return MessageIndex(id: MessageId(peerId: nextPeerId, namespace: self.id.namespace, id: self.id.id), timestamp: self.timestamp)
|
||||
@ -126,6 +138,10 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id == Int32.max ? self.id.id : (self.id.id + 1)), timestamp: self.timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
public func peerLocalSuccessor() -> MessageIndex {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id == Int32.max ? self.id.id : (self.id.id + 1)), timestamp: self.timestamp)
|
||||
}
|
||||
|
||||
public static func absoluteUpperBound() -> MessageIndex {
|
||||
return MessageIndex(id: MessageId(peerId: PeerId.max, namespace: Int32(Int8.max), id: Int32.max), timestamp: Int32.max)
|
||||
@ -217,11 +233,11 @@ public struct ChatListIndex: Comparable, Hashable {
|
||||
}
|
||||
|
||||
public var predecessor: ChatListIndex {
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.predecessor())
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.globalPredecessor())
|
||||
}
|
||||
|
||||
public var successor: ChatListIndex {
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.successor())
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.globalSuccessor())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ final class MessageHistoryReadStateTable: Table {
|
||||
readPastTopIndex = true
|
||||
}
|
||||
if maxIncomingReadIndex < messageIndex || markedUnread || readPastTopIndex {
|
||||
let (realDeltaCount, holes, messageIds) = incomingStatsInRange(maxIncomingReadIndex.successor(), messageIndex)
|
||||
let (realDeltaCount, holes, messageIds) = incomingStatsInRange(maxIncomingReadIndex.peerLocalSuccessor(), messageIndex)
|
||||
var deltaCount = realDeltaCount
|
||||
if readPastTopIndex {
|
||||
deltaCount = max(Int(count), deltaCount)
|
||||
@ -366,7 +366,7 @@ final class MessageHistoryReadStateTable: Table {
|
||||
break
|
||||
case let .indexBased(maxIncomingReadIndex, maxOutgoingReadIndex, count, markedUnread):
|
||||
if maxOutgoingReadIndex < messageIndex {
|
||||
let messageIds: [MessageId] = outgoingIndexStatsInRange(maxOutgoingReadIndex.successor(), messageIndex)
|
||||
let messageIds: [MessageId] = outgoingIndexStatsInRange(maxOutgoingReadIndex.peerLocalSuccessor(), messageIndex)
|
||||
|
||||
self.markReadStatesAsUpdated(messageIndex.id.peerId, namespaces: states.namespaces)
|
||||
states.namespaces[messageIndex.id.namespace] = .indexBased(maxIncomingReadIndex: maxIncomingReadIndex, maxOutgoingReadIndex: messageIndex, count: count, markedUnread: markedUnread)
|
||||
|
@ -1053,7 +1053,7 @@ public final class MessageHistoryView {
|
||||
index = 0
|
||||
for entry in entries {
|
||||
if entry.index.id.peerId == peerId && entry.index.id.namespace == namespace {
|
||||
maxNamespaceIndex = entry.index.predecessor()
|
||||
maxNamespaceIndex = entry.index.peerLocalPredecessor()
|
||||
break
|
||||
}
|
||||
index += 1
|
||||
@ -1109,7 +1109,7 @@ public final class MessageHistoryView {
|
||||
index = 0
|
||||
for entry in entries {
|
||||
if entry.index.id.peerId == peerId && entry.index.id.namespace == namespace {
|
||||
maxNamespaceIndex = entry.index.predecessor()
|
||||
maxNamespaceIndex = entry.index.peerLocalPredecessor()
|
||||
break
|
||||
}
|
||||
index += 1
|
||||
|
@ -468,11 +468,11 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.higherThanAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.higherThanAnchor[0].index.predecessor()
|
||||
let clipIndex = items.higherThanAnchor[0].index.peerLocalPredecessor()
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
} else {
|
||||
let clipIndex = items.lowerOrAtAnchor[0].index.predecessor()
|
||||
let clipIndex = items.lowerOrAtAnchor[0].index.peerLocalPredecessor()
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
} else {
|
||||
@ -480,7 +480,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.higherThanAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.higherThanAnchor[0].index.predecessor()
|
||||
let clipIndex = items.higherThanAnchor[0].index.peerLocalPredecessor()
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
} else {
|
||||
@ -488,7 +488,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if indices.contains(Int(items.lowerOrAtAnchor[i + 1].index.id.id)) {
|
||||
clipIndex = items.lowerOrAtAnchor[i + 1].index
|
||||
} else {
|
||||
clipIndex = items.lowerOrAtAnchor[i + 1].index.predecessor()
|
||||
clipIndex = items.lowerOrAtAnchor[i + 1].index.peerLocalPredecessor()
|
||||
}
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
@ -536,11 +536,11 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.lowerOrAtAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.successor()
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.peerLocalSuccessor()
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
} else {
|
||||
let clipIndex = items.higherThanAnchor[items.higherThanAnchor.count - 1].index.successor()
|
||||
let clipIndex = items.higherThanAnchor[items.higherThanAnchor.count - 1].index.peerLocalSuccessor()
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
} else {
|
||||
@ -548,7 +548,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.lowerOrAtAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.successor()
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.peerLocalSuccessor()
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
} else {
|
||||
@ -556,7 +556,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if indices.contains(Int(items.higherThanAnchor[i - 1].index.id.id)) {
|
||||
clipIndex = items.higherThanAnchor[i - 1].index
|
||||
} else {
|
||||
clipIndex = items.higherThanAnchor[i - 1].index.successor()
|
||||
clipIndex = items.higherThanAnchor[i - 1].index.peerLocalSuccessor()
|
||||
}
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ func fetchCallListHole(network: Network, postbox: Postbox, accountPeerId: PeerId
|
||||
|
||||
var updatedIndex: MessageIndex?
|
||||
if let topIndex = topIndex {
|
||||
updatedIndex = topIndex.predecessor()
|
||||
updatedIndex = topIndex.globalPredecessor()
|
||||
}
|
||||
|
||||
transaction.replaceGlobalMessageTagsHole(globalTags: [.Calls, .MissedCalls], index: holeIndex, with: updatedIndex, messages: storeMessages)
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -341,7 +341,7 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
|
||||
messageText = rawText
|
||||
}
|
||||
case .file:
|
||||
let rawText = presentationData.strings.PUSH_MESSAGE_DOCS(Int32(item.messages.count), peer.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), Int32(item.messages.count))
|
||||
let rawText = presentationData.strings.PUSH_MESSAGE_FILES(Int32(item.messages.count), peer.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), Int32(item.messages.count))
|
||||
if let index = rawText.firstIndex(of: "|") {
|
||||
title = String(rawText[rawText.startIndex ..< index])
|
||||
messageText = String(rawText[rawText.index(after: index)...])
|
||||
|
Loading…
x
Reference in New Issue
Block a user