mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 13:13:55 +00:00
Support for updated Postbox API
This commit is contained in:
parent
03f72c3abd
commit
221f351c54
@ -677,7 +677,7 @@ public final class AccountViewTracker {
|
||||
return
|
||||
}
|
||||
let _ = (account.postbox.transaction { transaction -> Set<MessageId> in
|
||||
let ids = Set(transaction.getMessageIndicesWithTag(peerId: peerId, tag: .unseenPersonalMessage).map({ $0.id }))
|
||||
let ids = Set(transaction.getMessageIndicesWithTag(peerId: peerId, namespace: Namespaces.Message.Cloud, tag: .unseenPersonalMessage).map({ $0.id }))
|
||||
if let summary = transaction.getMessageTagSummary(peerId: peerId, tagMask: .unseenPersonalMessage, namespace: Namespaces.Message.Cloud), summary.count > 0 {
|
||||
var maxId: Int32 = summary.range.maxId
|
||||
if let index = transaction.getTopPeerMessageIndex(peerId: peerId, namespace: Namespaces.Message.Cloud) {
|
||||
@ -892,27 +892,36 @@ public final class AccountViewTracker {
|
||||
}
|
||||
}
|
||||
|
||||
public func aroundMessageOfInterestHistoryViewForLocation(_ chatLocation: ChatLocation, count: Int, clipHoles: Bool = true, tagMask: MessageTags? = nil, orderStatistics: MessageHistoryViewOrderStatistics = [], additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> {
|
||||
public func aroundMessageOfInterestHistoryViewForLocation(_ chatLocation: ChatLocation, count: Int, tagMask: MessageTags? = nil, orderStatistics: MessageHistoryViewOrderStatistics = [], additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> {
|
||||
if let account = self.account {
|
||||
let signal = account.postbox.aroundMessageOfInterestHistoryViewForChatLocation(chatLocation, count: count, clipHoles: clipHoles, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, orderStatistics: orderStatistics, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
let signal = account.postbox.aroundMessageOfInterestHistoryViewForChatLocation(chatLocation, count: count, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, orderStatistics: orderStatistics, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
return wrappedMessageHistorySignal(chatLocation: chatLocation, signal: signal)
|
||||
} else {
|
||||
return .never()
|
||||
}
|
||||
}
|
||||
|
||||
public func aroundIdMessageHistoryViewForLocation(_ chatLocation: ChatLocation, count: Int, clipHoles: Bool = true, messageId: MessageId, tagMask: MessageTags? = nil, orderStatistics: MessageHistoryViewOrderStatistics = [], additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> {
|
||||
public func aroundIdMessageHistoryViewForLocation(_ chatLocation: ChatLocation, count: Int, messageId: MessageId, tagMask: MessageTags? = nil, orderStatistics: MessageHistoryViewOrderStatistics = [], additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> {
|
||||
if let account = self.account {
|
||||
let signal = account.postbox.aroundIdMessageHistoryViewForLocation(chatLocation, count: count, clipHoles: clipHoles, messageId: messageId, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, orderStatistics: orderStatistics, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
let signal = account.postbox.aroundIdMessageHistoryViewForLocation(chatLocation, count: count, messageId: messageId, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, orderStatistics: orderStatistics, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
return wrappedMessageHistorySignal(chatLocation: chatLocation, signal: signal)
|
||||
} else {
|
||||
return .never()
|
||||
}
|
||||
}
|
||||
|
||||
public func aroundMessageHistoryViewForLocation(_ chatLocation: ChatLocation, index: MessageHistoryAnchorIndex, anchorIndex: MessageHistoryAnchorIndex, count: Int, clipHoles: Bool = true, fixedCombinedReadStates: MessageHistoryViewReadState?, tagMask: MessageTags? = nil, orderStatistics: MessageHistoryViewOrderStatistics = [], additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> {
|
||||
public func aroundMessageHistoryViewForLocation(_ chatLocation: ChatLocation, index: MessageHistoryAnchorIndex, anchorIndex: MessageHistoryAnchorIndex, count: Int, fixedCombinedReadStates: MessageHistoryViewReadState?, tagMask: MessageTags? = nil, orderStatistics: MessageHistoryViewOrderStatistics = [], additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> {
|
||||
if let account = self.account {
|
||||
let signal = account.postbox.aroundMessageHistoryViewForLocation(chatLocation, index: index, anchorIndex: anchorIndex, count: count, clipHoles: clipHoles, fixedCombinedReadStates: fixedCombinedReadStates, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, orderStatistics: orderStatistics, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
let inputAnchor: HistoryViewInputAnchor
|
||||
switch index {
|
||||
case .upperBound:
|
||||
inputAnchor = .upperBound
|
||||
case .lowerBound:
|
||||
inputAnchor = .lowerBound
|
||||
case let .message(index):
|
||||
inputAnchor = .index(index)
|
||||
}
|
||||
let signal = account.postbox.aroundMessageHistoryViewForLocation(chatLocation, anchor: inputAnchor, count: count, fixedCombinedReadStates: fixedCombinedReadStates, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, orderStatistics: orderStatistics, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
return wrappedMessageHistorySignal(chatLocation: chatLocation, signal: signal)
|
||||
} else {
|
||||
return .never()
|
||||
|
||||
@ -77,7 +77,8 @@ private final class HistoryPreloadEntry: Comparable {
|
||||
|> take(1)
|
||||
|> deliverOn(queue)
|
||||
|> mapToSignal { download -> Signal<Never, NoError> in
|
||||
switch hole.hole {
|
||||
return .never()
|
||||
/*switch hole.hole {
|
||||
case let .peer(peerHole):
|
||||
let range: ClosedRange<MessageId.Id>
|
||||
switch hole.direction {
|
||||
@ -89,9 +90,7 @@ private final class HistoryPreloadEntry: Comparable {
|
||||
range = Int32(peerHole.indices[peerHole.indices.startIndex]) ... Int32.max
|
||||
}
|
||||
return fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .download(download), postbox: postbox, peerId: peerHole.peerId, namespace: peerHole.namespace, range: range, direction: hole.direction, space: .everywhere, limit: 60)
|
||||
/*case let .groupFeed(groupId, lowerIndex, upperIndex):
|
||||
return fetchGroupFeedHole(source: .download(download), accountPeerId: accountPeerId, postbox: postbox, groupId: groupId, minIndex: lowerIndex, maxIndex: upperIndex, direction: hole.direction, limit: 60)*/
|
||||
}
|
||||
}*/
|
||||
}
|
||||
)
|
||||
self.disposable.set(signal.start())
|
||||
|
||||
@ -128,15 +128,16 @@ public func clearAuthorHistory(account: Account, peerId: PeerId, memberId: PeerI
|
||||
return .fail(true)
|
||||
}
|
||||
}
|
||||
return (signal |> restart)
|
||||
|> `catch` { success -> Signal<Void, NoError> in
|
||||
if success {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
transaction.removeAllMessagesWithAuthor(peerId, authorId: memberId)
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
return (signal
|
||||
|> restart)
|
||||
|> `catch` { success -> Signal<Void, NoError> in
|
||||
if success {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
transaction.removeAllMessagesWithAuthor(peerId, authorId: memberId, namespace: Namespaces.Message.Cloud)
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
|
||||
@ -22,7 +22,7 @@ private func earliestUnseenPersonalMentionMessage(postbox: Postbox, network: Net
|
||||
return postbox.transaction { transaction -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> in
|
||||
var resultMessage: Message?
|
||||
var resultHole: MessageHistoryViewPeerHole?
|
||||
transaction.scanMessages(peerId: peerId, tagMask: .unseenPersonalMessage, { message in
|
||||
transaction.scanMessages(peerId: peerId, namespace: Namespaces.Message.Cloud, tag: .unseenPersonalMessage, { message in
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? ConsumablePersonalMentionMessageAttribute, !attribute.pending {
|
||||
resultMessage = message
|
||||
@ -58,7 +58,7 @@ private func earliestUnseenPersonalMentionMessage(postbox: Postbox, network: Net
|
||||
}
|
||||
|
||||
if !locally, let _ = invalidateHistoryPts {
|
||||
let validateSignal = fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .network(network), postbox: postbox, peerId: peerId, namespace: Namespaces.Message.Cloud, range: (resultMessage.id.id - 1) ... Int32.max, direction: .LowerToUpper, space: .tag(.unseenPersonalMessage), limit: 100)
|
||||
let validateSignal = fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .network(network), postbox: postbox, peerId: peerId, namespace: Namespaces.Message.Cloud, direction: .range(start: MessageId(peerId: resultMessage.id.peerId, namespace: resultMessage.id.namespace, id: resultMessage.id.id - 1), end: MessageId(peerId: resultMessage.id.peerId, namespace: resultMessage.id.namespace, id: Int32.max - 1)), space: .tag(.unseenPersonalMessage), limit: 100)
|
||||
|> `catch` { _ -> Signal<Never, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
@ -74,7 +74,7 @@ private func earliestUnseenPersonalMentionMessage(postbox: Postbox, network: Net
|
||||
}
|
||||
} else if let resultHole = resultHole, !locally {
|
||||
let holeRange = 1 ... Int32(resultHole.indices[resultHole.indices.endIndex] - 1)
|
||||
let validateSignal = fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .network(network), postbox: postbox, peerId: peerId, namespace: Namespaces.Message.Cloud, range: holeRange, direction: .LowerToUpper, space: .tag(.unseenPersonalMessage))
|
||||
let validateSignal = fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .network(network), postbox: postbox, peerId: peerId, namespace: Namespaces.Message.Cloud, direction: .range(start: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: 1), end: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: Int32.max - 1)), space: .tag(.unseenPersonalMessage))
|
||||
|> `catch` { _ -> Signal<Never, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ func withResolvedAssociatedMessages(postbox: Postbox, source: FetchMessageHistor
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryHoleSource, postbox: Postbox, peerId: PeerId, namespace: MessageId.Namespace, range: ClosedRange<MessageId.Id>, direction: MessageHistoryViewRelativeHoleDirection, space: MessageHistoryHoleSpace, limit: Int = 100) -> Signal<Never, NoError> {
|
||||
func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryHoleSource, postbox: Postbox, peerId: PeerId, namespace: MessageId.Namespace, direction: MessageHistoryViewRelativeHoleDirection, space: MessageHistoryHoleSpace, limit: Int = 100) -> Signal<Never, NoError> {
|
||||
return postbox.stateView()
|
||||
|> mapToSignal { view -> Signal<AuthorizedAccountState, NoError> in
|
||||
if let state = view.state as? AuthorizedAccountState {
|
||||
@ -139,7 +139,7 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
|> take(1)
|
||||
|> mapToSignal { peer in
|
||||
if let inputPeer = forceApiInputPeer(peer) {
|
||||
print("fetchMessageHistoryHole for \(peer.debugDisplayTitle) \(direction)")
|
||||
print("fetchMessageHistoryHole for \(peer.debugDisplayTitle) \(direction) space \(space)")
|
||||
let request: Signal<Api.messages.Messages, MTRpcError>
|
||||
var implicitelyFillHole = false
|
||||
switch space {
|
||||
@ -151,26 +151,23 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
let minId: Int32
|
||||
|
||||
switch direction {
|
||||
case .UpperToLower:
|
||||
offsetId = range.upperBound == Int32.max ? range.upperBound : (range.upperBound + 1)
|
||||
addOffset = 0
|
||||
maxId = range.upperBound == Int32.max ? range.upperBound : (range.upperBound + 1)
|
||||
minId = 1
|
||||
case .LowerToUpper:
|
||||
offsetId = range.lowerBound <= 1 ? 1 : (range.lowerBound - 1)
|
||||
addOffset = Int32(-selectedLimit)
|
||||
maxId = Int32.max
|
||||
minId = range.lowerBound - 1
|
||||
case let .AroundId(id):
|
||||
case let .range(start, end):
|
||||
if start.id <= end.id {
|
||||
offsetId = start.id <= 1 ? 1 : (start.id - 1)
|
||||
addOffset = Int32(-selectedLimit)
|
||||
maxId = end.id
|
||||
minId = start.id - 1
|
||||
} else {
|
||||
offsetId = start.id == Int32.max ? start.id : (start.id + 1)
|
||||
addOffset = 0
|
||||
maxId = start.id == Int32.max ? start.id : (start.id + 1)
|
||||
minId = end.id
|
||||
}
|
||||
case let .aroundId(id):
|
||||
offsetId = id.id
|
||||
addOffset = Int32(-selectedLimit / 2)
|
||||
maxId = Int32.max
|
||||
minId = 1
|
||||
case let .AroundIndex(index):
|
||||
offsetId = index.id.id
|
||||
addOffset = Int32(-selectedLimit / 2)
|
||||
maxId = Int32.max
|
||||
minId = 1
|
||||
}
|
||||
|
||||
request = source.request(Api.functions.messages.getHistory(peer: inputPeer, offsetId: offsetId, offsetDate: 0, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId, hash: 0))
|
||||
@ -184,36 +181,31 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
let minId: Int32
|
||||
|
||||
switch direction {
|
||||
case .UpperToLower:
|
||||
offsetId = range.upperBound == Int32.max ? range.upperBound : (range.upperBound + 1)
|
||||
addOffset = 0
|
||||
maxId = range.upperBound == Int32.max ? range.upperBound : (range.upperBound + 1)
|
||||
minId = 1
|
||||
case .LowerToUpper:
|
||||
offsetId = range.lowerBound <= 1 ? 1 : (range.lowerBound - 1)
|
||||
addOffset = Int32(-selectedLimit)
|
||||
maxId = Int32.max
|
||||
minId = range.lowerBound - 1
|
||||
case let .AroundId(id):
|
||||
case let .range(start, end):
|
||||
if start.id <= end.id {
|
||||
offsetId = start.id <= 1 ? 1 : (start.id - 1)
|
||||
addOffset = Int32(-selectedLimit)
|
||||
maxId = end.id
|
||||
minId = start.id - 1
|
||||
} else {
|
||||
offsetId = start.id == Int32.max ? start.id : (start.id + 1)
|
||||
addOffset = 0
|
||||
maxId = start.id == Int32.max ? start.id : (start.id + 1)
|
||||
minId = end.id
|
||||
}
|
||||
case let .aroundId(id):
|
||||
offsetId = id.id
|
||||
addOffset = Int32(-selectedLimit / 2)
|
||||
maxId = Int32.max
|
||||
minId = 1
|
||||
case let .AroundIndex(index):
|
||||
offsetId = index.id.id
|
||||
addOffset = Int32(-selectedLimit / 2)
|
||||
maxId = Int32.max
|
||||
minId = 1
|
||||
}
|
||||
request = source.request(Api.functions.messages.getUnreadMentions(peer: inputPeer, offsetId: offsetId, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId))
|
||||
} else if tag == .liveLocation {
|
||||
let selectedLimit = limit
|
||||
|
||||
switch direction {
|
||||
case .UpperToLower:
|
||||
case .aroundId, .range:
|
||||
implicitelyFillHole = true
|
||||
default:
|
||||
assertionFailure()
|
||||
}
|
||||
request = source.request(Api.functions.messages.getRecentLocations(peer: inputPeer, limit: Int32(selectedLimit), hash: 0))
|
||||
} else if let filter = messageFilterForTagMask(tag) {
|
||||
@ -224,26 +216,23 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
let minId: Int32
|
||||
|
||||
switch direction {
|
||||
case .UpperToLower:
|
||||
offsetId = range.upperBound == Int32.max ? range.upperBound : (range.upperBound + 1)
|
||||
addOffset = 0
|
||||
maxId = range.upperBound == Int32.max ? range.upperBound : (range.upperBound + 1)
|
||||
minId = 1
|
||||
case .LowerToUpper:
|
||||
offsetId = range.lowerBound <= 1 ? 1 : (range.lowerBound - 1)
|
||||
addOffset = Int32(-selectedLimit)
|
||||
maxId = Int32.max
|
||||
minId = range.lowerBound - 1
|
||||
case let .AroundId(id):
|
||||
case let .range(start, end):
|
||||
if start.id <= end.id {
|
||||
offsetId = start.id <= 1 ? 1 : (start.id - 1)
|
||||
addOffset = Int32(-selectedLimit)
|
||||
maxId = end.id
|
||||
minId = start.id - 1
|
||||
} else {
|
||||
offsetId = start.id == Int32.max ? start.id : (start.id + 1)
|
||||
addOffset = 0
|
||||
maxId = start.id == Int32.max ? start.id : (start.id + 1)
|
||||
minId = end.id
|
||||
}
|
||||
case let .aroundId(id):
|
||||
offsetId = id.id
|
||||
addOffset = Int32(-selectedLimit / 2)
|
||||
maxId = Int32.max
|
||||
minId = 1
|
||||
case let .AroundIndex(index):
|
||||
offsetId = index.id.id
|
||||
addOffset = Int32(-selectedLimit / 2)
|
||||
maxId = Int32.max
|
||||
minId = 1
|
||||
}
|
||||
request = source.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, filter: filter, minDate: 0, maxDate: 0, offsetId: offsetId, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId, hash: 0))
|
||||
} else {
|
||||
@ -294,27 +283,6 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
}
|
||||
}
|
||||
|
||||
/*var updatedMaxIndex: MessageIndex?
|
||||
if let maxIndexResult = maxIndexResult {
|
||||
let maxIndexMessages: [Api.Message]
|
||||
switch maxIndexResult {
|
||||
case let .messages(apiMessages, _, _):
|
||||
maxIndexMessages = apiMessages
|
||||
case let .messagesSlice(_, _, apiMessages, _, _):
|
||||
maxIndexMessages = apiMessages
|
||||
case let .channelMessages(_, _, _, apiMessages, _, _):
|
||||
maxIndexMessages = apiMessages
|
||||
case .messagesNotModified:
|
||||
maxIndexMessages = []
|
||||
}
|
||||
if !maxIndexMessages.isEmpty {
|
||||
assert(maxIndexMessages.count == 1)
|
||||
if let storeMessage = StoreMessage(apiMessage: maxIndexMessages[0]), case let .Id(id) = storeMessage.id {
|
||||
updatedMaxIndex = MessageIndex(id: id, timestamp: storeMessage.timestamp)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
var storeMessages: [StoreMessage] = []
|
||||
|
||||
for message in messages {
|
||||
@ -330,38 +298,27 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
}
|
||||
|
||||
return withResolvedAssociatedMessages(postbox: postbox, source: source, peers: Dictionary(peers.map({ ($0.id, $0) }), uniquingKeysWith: { lhs, _ in lhs }), storeMessages: storeMessages, { transaction, additionalPeers, additionalMessages in
|
||||
/*let fillDirection: HoleFillDirection
|
||||
switch direction {
|
||||
case .UpperToLower:
|
||||
fillDirection = .UpperToLower(updatedMinIndex: nil, clippingMaxIndex: nil)
|
||||
case .LowerToUpper:
|
||||
fillDirection = .LowerToUpper(updatedMaxIndex: updatedMaxIndex, clippingMinIndex: nil)
|
||||
case let .AroundId(id):
|
||||
fillDirection = .AroundId(id, lowerComplete: false, upperComplete: false)
|
||||
case let .AroundIndex(index):
|
||||
fillDirection = .AroundId(index.id, lowerComplete: false, upperComplete: false)
|
||||
}
|
||||
|
||||
var completeFill = messages.count == 0 || implicitelyFillHole
|
||||
if tagMask == .liveLocation {
|
||||
completeFill = false
|
||||
}
|
||||
transaction.fillMultipleHoles(hole, fillType: HoleFill(complete: completeFill, direction: fillDirection), tagMask: tagMask, messages: storeMessages)*/
|
||||
let _ = transaction.addMessages(storeMessages, location: .Random)
|
||||
let _ = transaction.addMessages(additionalMessages, location: .Random)
|
||||
let filledRange: ClosedRange<MessageId.Id>
|
||||
if messages.count == 0 || implicitelyFillHole {
|
||||
filledRange = range
|
||||
filledRange = 1 ... (Int32.max - 1)
|
||||
} else {
|
||||
let ids = messages.map({ $0.id!.id })
|
||||
let messageRange = ids.min()! ... ids.max()!
|
||||
switch direction {
|
||||
case .AroundId, .AroundIndex:
|
||||
case .aroundId:
|
||||
filledRange = messageRange
|
||||
case .LowerToUpper:
|
||||
filledRange = range.lowerBound ... messageRange.upperBound
|
||||
case .UpperToLower:
|
||||
filledRange = messageRange.lowerBound ... range.upperBound
|
||||
case let .range(start, end):
|
||||
if start.id <= end.id {
|
||||
let minBound = start.id
|
||||
let maxBound = messageRange.upperBound
|
||||
filledRange = min(minBound, maxBound) ... max(minBound, maxBound)
|
||||
} else {
|
||||
let minBound = messageRange.lowerBound
|
||||
let maxBound = start.id
|
||||
filledRange = min(minBound, maxBound) ... max(minBound, maxBound)
|
||||
}
|
||||
}
|
||||
}
|
||||
transaction.removeHole(peerId: peerId, namespace: namespace, space: space, range: filledRange)
|
||||
@ -371,7 +328,7 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
})
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
print("fetchMessageHistoryHole for \(peer.debugDisplayTitle) done")
|
||||
print("fetchMessageHistoryHole for \(peer.debugDisplayTitle) space \(space) done")
|
||||
|
||||
return
|
||||
})
|
||||
|
||||
@ -56,7 +56,7 @@ func managedMessageHistoryHoles(accountPeerId: PeerId, network: Network, postbox
|
||||
switch entry.hole {
|
||||
case let .peer(hole):
|
||||
let range: ClosedRange<MessageId.Id> = Int32(hole.indices[hole.indices.startIndex]) ... Int32(hole.indices[hole.indices.endIndex] - 1)
|
||||
disposable.set(fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .network(network), postbox: postbox, peerId: hole.peerId, namespace: hole.namespace, range: range, direction: entry.direction, space: entry.space).start())
|
||||
disposable.set(fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .network(network), postbox: postbox, peerId: hole.peerId, namespace: hole.namespace, direction: entry.direction, space: entry.space).start())
|
||||
/*case let .groupFeed(groupId, lowerIndex, upperIndex):
|
||||
disposable.set(fetchGroupFeedHole(source: .network(network), accountPeerId: accountPeerId, postbox: postbox, groupId: groupId, minIndex: lowerIndex, maxIndex: upperIndex, direction: entry.direction).start())*/
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user