no message

This commit is contained in:
overtake
2018-10-31 21:54:02 +04:00
parent 7a701322ae
commit 4e504e4103
3 changed files with 11 additions and 8 deletions

View File

@@ -90,7 +90,7 @@ private func extractKey(_ key: ValueBoxKey) -> (groupId: PeerGroupId?, pinningIn
private func readEntry(groupId: PeerGroupId?, messageHistoryTable: MessageHistoryTable, peerChatInterfaceStateTable: PeerChatInterfaceStateTable, key: ValueBoxKey, value: ReadBuffer) -> ChatListIntermediateEntry {
let (keyGroupId, pinningIndex, messageIndex, type) = extractKey(key)
assert(groupId == keyGroupId)
//preconditionFailure()
let index = ChatListIndex(pinningIndex: pinningIndex, messageIndex: messageIndex)
if type == ChatListEntryType.message.rawValue {
var message: IntermediateMessage?

View File

@@ -526,10 +526,13 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
var i = referenceIndex
var j = referenceIndex + 1
let lowerI = max(0, referenceIndex - 50)
let upperJ = min(referenceIndex + 50, self.entries.count)
switch self.location {
case let .group(groupId):
while i >= 0 || j < self.entries.count {
if j < self.entries.count {
while i >= lowerI || j < upperJ {
if j < upperJ {
if let hole = self.entries[j].hole {
switch anchorLocation {
case let .index(index):
@@ -552,7 +555,7 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
}
}
if i >= 0 {
if i >= lowerI {
if let hole = self.entries[i].hole {
switch anchorLocation {
case let .index(index):
@@ -598,8 +601,8 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
case let .index(index):
anchorId = index.id
}
while i >= 0 || j < self.entries.count {
if j < self.entries.count {
while i >= lowerI || j < upperJ {
if j < upperJ {
if let hole = self.entries[j].hole {
if anchorId.id >= hole.hole.min && anchorId.id <= hole.hole.maxIndex.id.id {
return MessageOfInterestHole(hole: .peer(hole.hole), direction: .AroundId(anchorId))
@@ -609,7 +612,7 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
}
}
if i >= 0 {
if i >= lowerI {
if let hole = self.entries[i].hole {
if anchorId.id >= hole.hole.min && anchorId.id <= hole.hole.maxIndex.id.id {
return MessageOfInterestHole(hole: .peer(hole.hole), direction: .AroundId(anchorId))

View File

@@ -24,7 +24,7 @@ public struct ValueBoxKey: Equatable, Hashable, CustomStringConvertible, Compara
}
public init(_ value: String) {
let data = value.data(using: .utf8, allowLossyConversion: true)!
let data = value.data(using: .utf8, allowLossyConversion: true) ?? Data()
self.memory = malloc(data.count)
self.length = data.count
self.impl = ValueBoxKeyImpl(memory: self.memory)