From 01e6511c8e80ab22e74abc8e8b0ce3e9f9c5f2a8 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 14 Jun 2018 12:48:57 +0300 Subject: [PATCH] no message --- Postbox/AccountManager.swift | 22 +++--- Postbox/ChatListIndexTable.swift | 10 ++- Postbox/Postbox.swift | 100 ++++++++++++++-------------- Postbox/PostboxUpgrade_17to18.swift | 4 +- 4 files changed, 71 insertions(+), 65 deletions(-) diff --git a/Postbox/AccountManager.swift b/Postbox/AccountManager.swift index 43f62d3439..e579751d77 100644 --- a/Postbox/AccountManager.swift +++ b/Postbox/AccountManager.swift @@ -41,12 +41,12 @@ public final class AccountManager { self.tables.append(self.recordTable) } - public func modify(_ f: @escaping (AccountManagerModifier) -> T) -> Signal { + public func transaction(_ f: @escaping (AccountManagerModifier) -> T) -> Signal { return Signal { subscriber in self.queue.justDispatch { self.valueBox.begin() - let modifier = AccountManagerModifier(getRecords: { + let transaction = AccountManagerModifier(getRecords: { return self.recordTable.getRecords() }, updateRecord: { id, update in let current = self.recordTable.getRecord(id: id) @@ -65,7 +65,7 @@ public final class AccountManager { return id }) - let result = f(modifier) + let result = f(transaction) self.beforeCommit() @@ -96,12 +96,12 @@ public final class AccountManager { } public func accountRecords() -> Signal { - return self.modify { modifier -> Signal in - return self.accountRecordsInternal(modifier: modifier) + return self.transaction { transaction -> Signal in + return self.accountRecordsInternal(transaction: transaction) } |> switchToLatest } - private func accountRecordsInternal(modifier: AccountManagerModifier) -> Signal { + private func accountRecordsInternal(transaction: AccountManagerModifier) -> Signal { let mutableView = MutableAccountRecordsView(getRecords: { return self.recordTable.getRecords() }, currentId: self.metadataTable.getCurrentAccountId()) @@ -120,20 +120,20 @@ public final class AccountManager { } public func allocatedCurrentAccountId() -> Signal { - return self.modify { modifier -> Signal in - let current = modifier.getCurrentId() + return self.transaction { transaction -> Signal in + let current = transaction.getCurrentId() let id: AccountRecordId if let current = current { id = current } else { id = generateAccountRecordId() - modifier.setCurrentId(id) - modifier.updateRecord(id, { _ in + transaction.setCurrentId(id) + transaction.updateRecord(id, { _ in return AccountRecord(id: id, attributes: []) }) } - let signal = self.accountRecordsInternal(modifier: modifier) |> map { view -> AccountRecordId? in + let signal = self.accountRecordsInternal(transaction: transaction) |> map { view -> AccountRecordId? in return view.currentRecord?.id } diff --git a/Postbox/ChatListIndexTable.swift b/Postbox/ChatListIndexTable.swift index 4a121a3480..a926c3a094 100644 --- a/Postbox/ChatListIndexTable.swift +++ b/Postbox/ChatListIndexTable.swift @@ -540,13 +540,19 @@ final class ChatListIndexTable: Table { let inclusion = self.get(peerId: peerId) if inclusion.includedIndex(peerId: peerId) != nil { if let combinedState = postbox.readStateTable.getCombinedState(peerId) { - state.absoluteCounters.messageCount += combinedState.count + state.absoluteCounters.messageCount = state.absoluteCounters.messageCount &+ combinedState.count + if state.absoluteCounters.messageCount < 0 { + state.absoluteCounters.messageCount = 0 + } if combinedState.isUnread { state.absoluteCounters.chatCount += 1 } if let notificationSettings = postbox.peerNotificationSettingsTable.getEffective(peerId), !notificationSettings.isRemovedFromTotalUnreadCount { - state.filteredCounters.messageCount += combinedState.count + state.filteredCounters.messageCount = state.filteredCounters.messageCount &+ combinedState.count + if state.filteredCounters.messageCount < 0 { + state.filteredCounters.messageCount = 0 + } if combinedState.isUnread { state.filteredCounters.chatCount += 1 } diff --git a/Postbox/Postbox.swift b/Postbox/Postbox.swift index 8c1dbd1836..7616639753 100644 --- a/Postbox/Postbox.swift +++ b/Postbox/Postbox.swift @@ -20,7 +20,7 @@ public enum ScanMessageEntry { case hole(MessageHistoryHole) } -public final class Modifier { +public final class Transaction { private weak var postbox: Postbox? var disposed = false @@ -41,7 +41,7 @@ public final class Modifier { public func addMessages(_ messages: [StoreMessage], location: AddMessagesLocation) -> [Int64: MessageId] { assert(!self.disposed) if let postbox = self.postbox { - return postbox.addMessages(modifier: self, messages: messages, location: location) + return postbox.addMessages(transaction: self, messages: messages, location: location) } else { return [:] } @@ -743,7 +743,7 @@ public final class Modifier { public func replaceGlobalMessageTagsHole(globalTags: GlobalMessageTags, index: MessageIndex, with updatedIndex: MessageIndex?, messages: [StoreMessage]) { assert(!self.disposed) - self.postbox?.replaceGlobalMessageTagsHole(modifier: self, globalTags: globalTags, index: index, with: updatedIndex, messages: messages) + self.postbox?.replaceGlobalMessageTagsHole(transaction: self, globalTags: globalTags, index: index, with: updatedIndex, messages: messages) } public func searchMessages(peerId: PeerId?, query: String, tags: MessageTags?) -> [Message] { @@ -1078,7 +1078,7 @@ public final class Postbox { //temporary let peerRatingTable: RatingTable - var installedMessageActionsByPeerId: [PeerId: Bag<([StoreMessage], Modifier) -> Void>] = [:] + var installedMessageActionsByPeerId: [PeerId: Bag<([StoreMessage], Transaction) -> Void>] = [:] fileprivate init(queue: Queue, basePath: String, globalMessageIdsNamespace: MessageId.Namespace, seedConfiguration: SeedConfiguration, valueBox: ValueBox) { assert(queue.isCurrent()) @@ -1285,7 +1285,7 @@ public final class Postbox { let semaphore = DispatchSemaphore(value: 0) var entry: Data? = nil - let disposable = (self.modify({ modifier -> Data? in + let disposable = (self.transaction({ transaction -> Data? in return self.keychainTable.get(key) }) |> afterDisposed { [weak self, weak metaDisposable] in if let strongSelf = self, let metaDisposable = metaDisposable { @@ -1307,7 +1307,7 @@ public final class Postbox { let metaDisposable = MetaDisposable() self.keychainOperationsDisposable.add(metaDisposable) - let disposable = (self.modify({ modifier -> Void in + let disposable = (self.transaction({ transaction -> Void in self.keychainTable.set(key, value: value) }) |> afterDisposed { [weak self, weak metaDisposable] in if let strongSelf = self, let metaDisposable = metaDisposable { @@ -1321,7 +1321,7 @@ public final class Postbox { let metaDisposable = MetaDisposable() self.keychainOperationsDisposable.add(metaDisposable) - let disposable = (self.modify({ modifier -> Void in + let disposable = (self.transaction({ transaction -> Void in self.keychainTable.remove(key) }) |> afterDisposed { [weak self, weak metaDisposable] in if let strongSelf = self, let metaDisposable = metaDisposable { @@ -1331,7 +1331,7 @@ public final class Postbox { metaDisposable.set(disposable) } - fileprivate func addMessages(modifier: Modifier, messages: [StoreMessage], location: AddMessagesLocation) -> [Int64: MessageId] { + fileprivate func addMessages(transaction: Transaction, messages: [StoreMessage], location: AddMessagesLocation) -> [Int64: MessageId] { var addedMessagesByPeerId: [PeerId: [StoreMessage]] = [:] let addResult = self.messageHistoryTable.addMessages(messages: messages, location: location, operationsByPeerId: &self.currentOperationsByPeerId, updatedMedia: &self.currentUpdatedMedia, unsentMessageOperations: ¤tUnsentOperations, updatedPeerReadStateOperations: &self.currentUpdatedSynchronizeReadStateOperations, globalTagsOperations: &self.currentGlobalTagsOperations, pendingActionsOperations: &self.currentPendingMessageActionsOperations, updatedMessageActionsSummaries: &self.currentUpdatedMessageActionsSummaries, updatedMessageTagSummaries: &self.currentUpdatedMessageTagSummaries, invalidateMessageTagSummaries: &self.currentInvalidateMessageTagSummaries, groupFeedOperations: &self.currentGroupFeedOperations, localTagsOperations: &self.currentLocalTagsOperations, processMessages: { messagesByPeerId in addedMessagesByPeerId = messagesByPeerId @@ -1339,7 +1339,7 @@ public final class Postbox { for (peerId, peerMessages) in addedMessagesByPeerId { if let bag = self.installedMessageActionsByPeerId[peerId] { for f in bag.copyItems() { - f(peerMessages, modifier) + f(peerMessages, transaction) } } } @@ -2132,7 +2132,7 @@ public final class Postbox { self.itemCacheTable.remove(id: id, metaTable: self.itemCacheMetaTable) } - fileprivate func replaceGlobalMessageTagsHole(modifier: Modifier, globalTags: GlobalMessageTags, index: MessageIndex, with updatedIndex: MessageIndex?, messages: [StoreMessage]) { + fileprivate func replaceGlobalMessageTagsHole(transaction: Transaction, globalTags: GlobalMessageTags, index: MessageIndex, with updatedIndex: MessageIndex?, messages: [StoreMessage]) { var allTagsMatch = true for tag in globalTags { self.globalMessageHistoryTagsTable.ensureInitialized(tag) @@ -2154,7 +2154,7 @@ public final class Postbox { } } - let _ = self.addMessages(modifier: modifier, messages: messages, location: .Random) + let _ = self.addMessages(transaction: transaction, messages: messages, location: .Random) } } @@ -2227,12 +2227,12 @@ public final class Postbox { } } - private func internalTransaction(_ f: (Modifier) -> T) -> (result: T, updatedTransactionStateVersion: Int64?, updatedMasterClientId: Int64?) { + private func internalTransaction(_ f: (Transaction) -> T) -> (result: T, updatedTransactionStateVersion: Int64?, updatedMasterClientId: Int64?) { self.valueBox.begin() self.afterBegin() - let modifier = Modifier(postbox: self) - let result = f(modifier) - modifier.disposed = true + let transaction = Transaction(postbox: self) + let result = f(transaction) + transaction.disposed = true let (updatedTransactionState, updatedMasterClientId) = self.beforeCommit() self.valueBox.commit() @@ -2244,14 +2244,14 @@ public final class Postbox { return (result, updatedTransactionState, updatedMasterClientId) } - public func transactionSignal(userInteractive: Bool = false, _ f: @escaping(Subscriber, Modifier) -> Disposable) -> Signal { + public func transactionSignal(userInteractive: Bool = false, _ f: @escaping(Subscriber, Transaction) -> Disposable) -> Signal { return Signal { subscriber in let disposable = MetaDisposable() let f: () -> Void = { self.beginInternalTransaction { - let (_, updatedTransactionState, updatedMasterClientId) = self.internalTransaction({ modifier in - disposable.set(f(subscriber, modifier)) + let (_, updatedTransactionState, updatedMasterClientId) = self.internalTransaction({ transaction in + disposable.set(f(subscriber, transaction)) }) if updatedTransactionState != nil || updatedMasterClientId != nil { @@ -2273,12 +2273,12 @@ public final class Postbox { } } - public func modify(userInteractive: Bool = false, ignoreDisabled: Bool = false, _ f: @escaping(Modifier) -> T) -> Signal { + public func transaction(userInteractive: Bool = false, ignoreDisabled: Bool = false, _ f: @escaping(Transaction) -> T) -> Signal { return Signal { subscriber in let f: () -> Void = { self.beginInternalTransaction(ignoreDisabled: ignoreDisabled, { - let (result, updatedTransactionState, updatedMasterClientId) = self.internalTransaction({ modifier in - return f(modifier) + let (result, updatedTransactionState, updatedMasterClientId) = self.internalTransaction({ transaction in + return f(transaction) }) if updatedTransactionState != nil || updatedMasterClientId != nil { @@ -2317,7 +2317,7 @@ public final class Postbox { } public func aroundMessageOfInterestHistoryViewForChatLocation(_ chatLocation: ChatLocation, count: Int, clipHoles: Bool, topTaggedMessageIdNamespaces: Set, tagMask: MessageTags?, orderStatistics: MessageHistoryViewOrderStatistics, additionalData: [AdditionalMessageHistoryViewData]) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> { - return self.transactionSignal(userInteractive: true, { subscriber, modifier in + return self.transactionSignal(userInteractive: true, { subscriber, transaction in let peerIds = self.peerIdsForLocation(chatLocation, tagMask: tagMask) var index: InitialMessageHistoryViewAnchorIndex = .index(.upperBound) @@ -2382,7 +2382,7 @@ public final class Postbox { } public func aroundIdMessageHistoryViewForLocation(_ chatLocation: ChatLocation, count: Int, clipHoles: Bool, messageId: MessageId, topTaggedMessageIdNamespaces: Set, tagMask: MessageTags?, orderStatistics: MessageHistoryViewOrderStatistics, additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let peerIds = self.peerIdsForLocation(chatLocation, tagMask: tagMask) var index: InternalMessageHistoryAnchorIndex = .upperBound @@ -2398,7 +2398,7 @@ public final class Postbox { } public func aroundMessageHistoryViewForLocation(_ chatLocation: ChatLocation, index: MessageHistoryAnchorIndex, anchorIndex: MessageHistoryAnchorIndex, count: Int, clipHoles: Bool, fixedCombinedReadStates: MessageHistoryViewReadState?, topTaggedMessageIdNamespaces: Set, tagMask: MessageTags?, orderStatistics: MessageHistoryViewOrderStatistics, additionalData: [AdditionalMessageHistoryViewData] = []) -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let peerIds = self.peerIdsForLocation(chatLocation, tagMask: tagMask) return self.syncAroundMessageHistoryViewForPeerId(subscriber: subscriber, peerIds: peerIds, count: count, clipHoles: clipHoles, index: .index(InternalMessageHistoryAnchorIndex(index)), anchorIndex: InternalMessageHistoryAnchorIndex(anchorIndex), unreadIndex: nil, fixedCombinedReadStates: fixedCombinedReadStates, topTaggedMessageIdNamespaces: topTaggedMessageIdNamespaces, tagMask: tagMask, orderStatistics: orderStatistics, additionalData: additionalData) @@ -2530,7 +2530,7 @@ public final class Postbox { } public func messageIndexAtId(_ id: MessageId) -> Signal { - return self.modify { modifier -> Signal in + return self.transaction { transaction -> Signal in if let entry = self.messageHistoryIndexTable.get(id), case let .Message(index) = entry { return .single(index) } else if let _ = self.messageHistoryIndexTable.holeContainingId(id) { @@ -2542,7 +2542,7 @@ public final class Postbox { } public func messageAtId(_ id: MessageId) -> Signal { - return self.modify { modifier -> Signal in + return self.transaction { transaction -> Signal in if let entry = self.messageHistoryIndexTable.get(id), case let .Message(index) = entry { if let message = self.messageHistoryTable.getMessage(index) { return .single(self.renderIntermediateMessage(message)) @@ -2558,7 +2558,7 @@ public final class Postbox { } public func messagesAtIds(_ ids: [MessageId]) -> Signal<[Message], NoError> { - return self.modify { modifier -> Signal<[Message], NoError> in + return self.transaction { transaction -> Signal<[Message], NoError> in var messages: [Message] = [] for id in ids { if let entry = self.messageHistoryIndexTable.get(id), case let .Message(index) = entry { @@ -2576,7 +2576,7 @@ public final class Postbox { } public func aroundChatListView(groupId: PeerGroupId?, index: ChatListIndex, count: Int, summaryComponents: ChatListEntrySummaryComponents) -> Signal<(ChatListView, ViewUpdateType), NoError> { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let (entries, earlier, later) = self.fetchAroundChatEntries(groupId: groupId, index: index, count: count) let mutableView = MutableChatListView(postbox: self, groupId: groupId, earlier: earlier, entries: entries, later: later, count: count, summaryComponents: summaryComponents) @@ -2603,7 +2603,7 @@ public final class Postbox { } public func contactPeerIdsView() -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutableContactPeerIdsView(remoteTotalCount: self.metadataTable.getRemoteContactCount(), peerIds: self.contactsTable.get()) let (index, signal) = self.viewTracker.addContactPeerIdsView(view) @@ -2625,7 +2625,7 @@ public final class Postbox { } public func contactPeersView(accountPeerId: PeerId?, includePresences: Bool) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in var peers: [PeerId: Peer] = [:] var peerPresences: [PeerId: PeerPresence] = [:] @@ -2661,7 +2661,7 @@ public final class Postbox { } public func searchContacts(query: String) -> Signal<[Peer], NoError> { - return self.modify { modifier -> Signal<[Peer], NoError> in + return self.transaction { transaction -> Signal<[Peer], NoError> in let (_, contactPeerIds) = self.peerNameIndexTable.matchingPeerIds(tokens: (regular: stringIndexTokens(query, transliteration: .none), transliterated: stringIndexTokens(query, transliteration: .transliterated)), categories: [.contacts], chatListIndexTable: self.chatListIndexTable, contactTable: self.contactsTable, reverseAssociatedPeerTable: self.reverseAssociatedPeerTable) var contactPeers: [Peer] = [] @@ -2677,7 +2677,7 @@ public final class Postbox { } public func searchPeers(query: String, groupId: PeerGroupId?) -> Signal<[RenderedPeer], NoError> { - return self.modify { modifier -> Signal<[RenderedPeer], NoError> in + return self.transaction { transaction -> Signal<[RenderedPeer], NoError> in var peerIds = Set() var chatPeers: [RenderedPeer] = [] @@ -2730,7 +2730,7 @@ public final class Postbox { } public func peerView(id: PeerId) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutablePeerView(postbox: self, peerId: id) let (index, signal) = self.viewTracker.addPeerView(view) @@ -2752,7 +2752,7 @@ public final class Postbox { } public func multiplePeersView(_ ids: [PeerId]) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutableMultiplePeersView(peerIds: ids, getPeer: { self.peerTable.get($0) }, getPeerPresence: { self.peerPresenceTable.get($0) }) let (index, signal) = self.viewTracker.addMultiplePeersView(view) @@ -2774,7 +2774,7 @@ public final class Postbox { } public func loadedPeerWithId(_ id: PeerId) -> Signal { - return self.modify { modifier -> Signal in + return self.transaction { transaction -> Signal in if let peer = self.peerTable.get(id) { return .single(peer) } else { @@ -2784,7 +2784,7 @@ public final class Postbox { } public func unreadMessageCountsView(items: [UnreadMessageCountsItem]) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutableUnreadMessageCountsView(postbox: self, items: items) let (index, signal) = self.viewTracker.addUnreadMessageCountsView(view) @@ -2806,13 +2806,13 @@ public final class Postbox { } public func updateMessageHistoryViewVisibleRange(_ id: MessageHistoryViewId, earliestVisibleIndex: MessageIndex, latestVisibleIndex: MessageIndex) { - let _ = self.modify({ modifier -> Void in + let _ = self.transaction({ transaction -> Void in self.viewTracker.updateMessageHistoryViewVisibleRange(postbox: self, id: id, earliestVisibleIndex: earliestVisibleIndex, latestVisibleIndex: latestVisibleIndex) }).start() } public func recentPeers() -> Signal<[Peer], NoError> { - return self.modify { modifier -> Signal<[Peer], NoError> in + return self.transaction { transaction -> Signal<[Peer], NoError> in let peerIds = self.peerRatingTable.get() var peers: [Peer] = [] for peerId in peerIds { @@ -2825,7 +2825,7 @@ public final class Postbox { } public func stateView() -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let mutableView = MutablePostboxStateView(state: self.getState()) subscriber.putNext(PostboxStateView(mutableView)) @@ -2896,7 +2896,7 @@ public final class Postbox { } public func itemCollectionsView(orderedItemListCollectionIds: [Int32], namespaces: [ItemCollectionId.Namespace], aroundIndex: ItemCollectionViewEntryIndex?, count: Int) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let itemListViews = orderedItemListCollectionIds.map { collectionId -> MutableOrderedItemListView in return MutableOrderedItemListView(postbox: self, collectionId: collectionId) } @@ -2923,7 +2923,7 @@ public final class Postbox { } public func mergedOperationLogView(tag: PeerOperationLogTag, limit: Int) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutablePeerMergedOperationLogView(tag: tag, limit: limit, getOperations: { tag, fromIndex, limit in return self.peerOperationLogTable.getMergedEntries(tag: tag, fromIndex: fromIndex, limit: limit) }, getTailIndex: { tag in @@ -2950,7 +2950,7 @@ public final class Postbox { } public func timestampBasedMessageAttributesView(tag: UInt16) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutableTimestampBasedMessageAttributesView(tag: tag, getHead: { tag in return self.timestampBasedMessageAttributesTable.head(tag: tag) }) @@ -3010,8 +3010,8 @@ public final class Postbox { } public func messageView(_ messageId: MessageId) -> Signal { - return self.transactionSignal { subscriber, modifier in - let view = MutableMessageView(messageId: messageId, message: modifier.getMessage(messageId)) + return self.transactionSignal { subscriber, transaction in + let view = MutableMessageView(messageId: messageId, message: transaction.getMessage(messageId)) subscriber.putNext(MessageView(view)) @@ -3033,7 +3033,7 @@ public final class Postbox { } public func preferencesView(keys: [ValueBoxKey]) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in let view = MutablePreferencesView(postbox: self, keys: Set(keys)) let (index, signal) = self.viewTracker.addPreferencesView(view) @@ -3055,7 +3055,7 @@ public final class Postbox { } public func combinedView(keys: [PostboxViewKey]) -> Signal { - return self.transactionSignal { subscriber, modifier in + return self.transactionSignal { subscriber, transaction in var views: [PostboxViewKey: MutablePostboxView] = [:] for key in keys { views[key] = postboxViewForKey(postbox: self, key: key) @@ -3117,7 +3117,7 @@ public final class Postbox { self.metadataTable.setAccessChallengeData(data) } - public func installStoreMessageAction(peerId: PeerId, _ f: @escaping ([StoreMessage], Modifier) -> Void) -> Disposable { + public func installStoreMessageAction(peerId: PeerId, _ f: @escaping ([StoreMessage], Transaction) -> Void) -> Disposable { let disposable = MetaDisposable() self.queue.async { if self.installedMessageActionsByPeerId[peerId] == nil { @@ -3217,7 +3217,7 @@ public final class Postbox { } public func isMasterClient() -> Signal { - return self.modify { modifier -> Signal in + return self.transaction { transaction -> Signal in let sessionClientId = self.sessionClientId return self.masterClientId.get() |> distinctUntilChanged @@ -3226,7 +3226,7 @@ public final class Postbox { } public func becomeMasterClient() { - let _ = self.modify({ modifier in + let _ = self.transaction({ transaction in if self.metadataTable.masterClientId() != self.sessionClientId { self.currentUpdatedMasterClientId = self.sessionClientId } @@ -3234,7 +3234,7 @@ public final class Postbox { } public func clearCaches() { - let _ = self.modify({ _ in + let _ = self.transaction({ _ in for table in self.tables { table.clearMemoryCache() } diff --git a/Postbox/PostboxUpgrade_17to18.swift b/Postbox/PostboxUpgrade_17to18.swift index 14a4bc0c4c..60f904e0b4 100644 --- a/Postbox/PostboxUpgrade_17to18.swift +++ b/Postbox/PostboxUpgrade_17to18.swift @@ -47,7 +47,7 @@ private func convertNamespaces(value: ReadBuffer, buffer: WriteBuffer) { value.read(&maxIncomingReadTimestamp, offset: 0, length: 4) buffer.write(&maxIncomingReadTimestamp, offset: 0, length: 4) value.read(&maxIncomingReadIdPeerId, offset: 0, length: 8) - buffer.write(&maxIncomingReadIdPeerId, offset: 0, length: 4) + buffer.write(&maxIncomingReadIdPeerId, offset: 0, length: 8) value.read(&maxIncomingReadIdNamespace, offset: 0, length: 4) buffer.write(&maxIncomingReadIdNamespace, offset: 0, length: 4) value.read(&maxIncomingReadIdId, offset: 0, length: 4) @@ -56,7 +56,7 @@ private func convertNamespaces(value: ReadBuffer, buffer: WriteBuffer) { value.read(&maxOutgoingReadTimestamp, offset: 0, length: 4) buffer.write(&maxOutgoingReadTimestamp, offset: 0, length: 4) value.read(&maxOutgoingReadIdPeerId, offset: 0, length: 8) - buffer.write(&maxOutgoingReadIdPeerId, offset: 0, length: 4) + buffer.write(&maxOutgoingReadIdPeerId, offset: 0, length: 8) value.read(&maxOutgoingReadIdNamespace, offset: 0, length: 4) buffer.write(&maxOutgoingReadIdNamespace, offset: 0, length: 4) value.read(&maxOutgoingReadIdId, offset: 0, length: 4)