Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2020-09-24 11:13:31 +03:00
commit fd60c76855
8 changed files with 23 additions and 17 deletions

View File

@ -81,6 +81,7 @@ final class MessageHistoryMetadataTable: Table {
private func peerThreadHoleIndexInitializedKey(peerId: PeerId, threadId: Int64) -> ValueBoxKey { private func peerThreadHoleIndexInitializedKey(peerId: PeerId, threadId: Int64) -> ValueBoxKey {
self.sharedPeerThreadHoleIndexInitializedKey.setInt64(0, value: peerId.toInt64()) self.sharedPeerThreadHoleIndexInitializedKey.setInt64(0, value: peerId.toInt64())
self.sharedPeerThreadHoleIndexInitializedKey.setInt8(8, value: MetadataPrefix.PeerHistoryThreadHoleIndexInitialized.rawValue) self.sharedPeerThreadHoleIndexInitializedKey.setInt8(8, value: MetadataPrefix.PeerHistoryThreadHoleIndexInitialized.rawValue)
self.sharedPeerThreadHoleIndexInitializedKey.setInt64(0, value: threadId)
return self.sharedPeerThreadHoleIndexInitializedKey return self.sharedPeerThreadHoleIndexInitializedKey
} }

View File

@ -110,6 +110,7 @@ final class MessageHistoryThreadHoleIndexTable: Table {
private func ensureInitialized(peerId: PeerId, threadId: Int64) { private func ensureInitialized(peerId: PeerId, threadId: Int64) {
if !self.metadataTable.isThreadHoleIndexInitialized(peerId: peerId, threadId: threadId) { if !self.metadataTable.isThreadHoleIndexInitialized(peerId: peerId, threadId: threadId) {
postboxLog("MessageHistoryThreadHoleIndexTable: Initializing \(peerId) \(threadId)")
self.metadataTable.setIsThreadHoleIndexInitialized(peerId: peerId, threadId: threadId) self.metadataTable.setIsThreadHoleIndexInitialized(peerId: peerId, threadId: threadId)
if let messageNamespaces = self.seedConfiguration.messageThreadHoles[peerId.namespace] { if let messageNamespaces = self.seedConfiguration.messageThreadHoles[peerId.namespace] {

View File

@ -162,7 +162,7 @@ func mergeChannel(lhs: TelegramChannel?, rhs: TelegramChannel) -> TelegramChanne
return rhs return rhs
} }
if case .personal = rhs.accessHash { if case .personal? = rhs.accessHash {
return rhs return rhs
} }
@ -185,9 +185,9 @@ func mergeChannel(lhs: TelegramChannel?, rhs: TelegramChannel) -> TelegramChanne
if let rhsAccessHashValue = lhs.accessHash, case .personal = rhsAccessHashValue { if let rhsAccessHashValue = lhs.accessHash, case .personal = rhsAccessHashValue {
accessHash = rhsAccessHashValue accessHash = rhsAccessHashValue
} else { } else {
accessHash = lhs.accessHash ?? rhs.accessHash accessHash = rhs.accessHash ?? lhs.accessHash
} }
return TelegramChannel(id: lhs.id, accessHash: accessHash, title: rhs.title, username: rhs.username, photo: rhs.photo, creationDate: lhs.creationDate, version: lhs.version, participationStatus: lhs.participationStatus, info: info, flags: channelFlags, restrictionInfo: lhs.restrictionInfo, adminRights: lhs.adminRights, bannedRights: lhs.bannedRights, defaultBannedRights: rhs.defaultBannedRights) return TelegramChannel(id: lhs.id, accessHash: accessHash, title: rhs.title, username: rhs.username, photo: rhs.photo, creationDate: rhs.creationDate, version: rhs.version, participationStatus: rhs.participationStatus, info: info, flags: channelFlags, restrictionInfo: rhs.restrictionInfo, adminRights: rhs.adminRights, bannedRights: rhs.bannedRights, defaultBannedRights: rhs.defaultBannedRights)
} }

View File

@ -219,15 +219,17 @@ public final class BlockedPeersContext {
} }
|> mapToSignal { value in |> mapToSignal { value in
return postbox.transaction { transaction -> Peer? in return postbox.transaction { transaction -> Peer? in
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in if peerId.namespace == Namespaces.Peer.CloudUser {
let previous: CachedUserData transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if let current = current as? CachedUserData { let previous: CachedUserData
previous = current if let current = current as? CachedUserData {
} else { previous = current
previous = CachedUserData() } else {
} previous = CachedUserData()
return previous.withUpdatedIsBlocked(false) }
}) return previous.withUpdatedIsBlocked(false)
})
}
return transaction.getPeer(peerId) return transaction.getPeer(peerId)
} }
|> castError(BlockedPeersContextRemoveError.self) |> castError(BlockedPeersContextRemoveError.self)

View File

@ -574,6 +574,8 @@ private final class CallSessionManagerContext {
self.ringingStatesUpdated() self.ringingStatesUpdated()
} }
} }
} else {
self.contextUpdated(internalId: internalId)
} }
} }

View File

@ -479,7 +479,7 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa
let key = SharedContextStore.Key(accountId: accountId) let key = SharedContextStore.Key(accountId: accountId)
let context: MTContext let context: MTContext
if let current = store.contexts[key] { if false, let current = store.contexts[key] {
context = current context = current
context.updateApiEnvironment({ _ in return apiEnvironment}) context.updateApiEnvironment({ _ in return apiEnvironment})
} else { } else {

View File

@ -143,7 +143,7 @@ extension TelegramUser {
guard let lhs = lhs else { guard let lhs = lhs else {
return rhs return rhs
} }
if case .personal = rhs.accessHash { if case .personal? = rhs.accessHash {
return rhs return rhs
} else { } else {
var userFlags: UserInfoFlags = [] var userFlags: UserInfoFlags = []

View File

@ -85,14 +85,14 @@ private func updateMessageThreadStatsInternal(transaction: Transaction, threadMe
let count = max(0, attribute.count + countDifference) let count = max(0, attribute.count + countDifference)
var maxMessageId = attribute.maxMessageId var maxMessageId = attribute.maxMessageId
var maxReadMessageId = attribute.maxReadMessageId var maxReadMessageId = attribute.maxReadMessageId
if let maxAddedId = addedMessagePeers.map(\.messageId.id).max() { if let maxAddedId = addedMessagePeers.map({ $0.messageId.id }).max() {
if let currentMaxMessageId = maxMessageId { if let currentMaxMessageId = maxMessageId {
maxMessageId = max(currentMaxMessageId, maxAddedId) maxMessageId = max(currentMaxMessageId, maxAddedId)
} else { } else {
maxMessageId = maxAddedId maxMessageId = maxAddedId
} }
} }
if let maxAddedReadId = addedMessagePeers.filter(\.isOutgoing).map(\.messageId.id).max() { if let maxAddedReadId = addedMessagePeers.filter({ $0.isOutgoing }).map({ $0.messageId.id }).max() {
if let currentMaxMessageId = maxReadMessageId { if let currentMaxMessageId = maxReadMessageId {
maxReadMessageId = max(currentMaxMessageId, maxAddedReadId) maxReadMessageId = max(currentMaxMessageId, maxAddedReadId)
} else { } else {
@ -100,7 +100,7 @@ private func updateMessageThreadStatsInternal(transaction: Transaction, threadMe
} }
} }
attributes[j] = ReplyThreadMessageAttribute(count: count, latestUsers: mergeLatestUsers(current: attribute.latestUsers, added: addedMessagePeers.map(\.id), isGroup: isGroup, isEmpty: count == 0), commentsPeerId: attribute.commentsPeerId, maxMessageId: maxMessageId, maxReadMessageId: maxReadMessageId) attributes[j] = ReplyThreadMessageAttribute(count: count, latestUsers: mergeLatestUsers(current: attribute.latestUsers, added: addedMessagePeers.map({ $0.id }), isGroup: isGroup, isEmpty: count == 0), commentsPeerId: attribute.commentsPeerId, maxMessageId: maxMessageId, maxReadMessageId: maxReadMessageId)
} else if let attribute = attributes[j] as? SourceReferenceMessageAttribute { } else if let attribute = attributes[j] as? SourceReferenceMessageAttribute {
channelThreadMessageId = attribute.messageId channelThreadMessageId = attribute.messageId
} }