Skip to content

Commit fe9979d

Browse files
authored
Merge pull request #353 from session-foundation/dev
Release 2.8.5
2 parents 94fce5e + 3a91bc5 commit fe9979d

File tree

96 files changed

+1759
-1516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1759
-1516
lines changed

Session.xcodeproj/project.pbxproj

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
7BC01A3E241F40AB00BC7C55 /* NotificationServiceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC01A3D241F40AB00BC7C55 /* NotificationServiceExtension.swift */; };
157157
7BC01A42241F40AB00BC7C55 /* SessionNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7BC01A3B241F40AB00BC7C55 /* SessionNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
158158
7BC707F227290ACB002817AD /* SessionCallManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC707F127290ACB002817AD /* SessionCallManager.swift */; };
159-
7BD477A827EC39F5004E2822 /* Atomic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD477A727EC39F5004E2822 /* Atomic.swift */; };
160159
7BD687D12A5D0D1200D8E455 /* MessageInfoScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD687D02A5D0D1200D8E455 /* MessageInfoScreen.swift */; };
161160
7BD976972A776C76001B466F /* SessionCarouselView+SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BE2701D2A64C11500CEB71A /* SessionCarouselView+SwiftUI.swift */; };
162161
7BDCFC08242186E700641C39 /* NotificationServiceExtensionContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDCFC07242186E700641C39 /* NotificationServiceExtensionContext.swift */; };
@@ -817,6 +816,9 @@
817816
FD96F3A729DBD43D00401309 /* MockJobRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD96F3A629DBD43D00401309 /* MockJobRunner.swift */; };
818817
FD97B2402A3FEB050027DD57 /* ARC4RandomNumberGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD97B23F2A3FEB050027DD57 /* ARC4RandomNumberGenerator.swift */; };
819818
FD97B2422A3FEBF30027DD57 /* UnreadMarkerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD97B2412A3FEBF30027DD57 /* UnreadMarkerCell.swift */; };
819+
FD99D0872D0FA731005D2E15 /* ThreadSafe.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD99D0862D0FA72E005D2E15 /* ThreadSafe.swift */; };
820+
FD99D0902D10E71B005D2E15 /* NSCache+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD99D08F2D10E718005D2E15 /* NSCache+Utilities.swift */; };
821+
FD99D0922D10F5EE005D2E15 /* ThreadSafeSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD99D0912D10F5EB005D2E15 /* ThreadSafeSpec.swift */; };
820822
FD9AECA52AAA9609009B3406 /* NotificationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9AECA42AAA9609009B3406 /* NotificationError.swift */; };
821823
FD9B30F3293EA0BF008DEE3E /* BatchResponseSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9B30F2293EA0BF008DEE3E /* BatchResponseSpec.swift */; };
822824
FD9BDE002A5D22B7005F1EBC /* libSessionUtil.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD9BDDF82A5D2294005F1EBC /* libSessionUtil.a */; };
@@ -1358,7 +1360,6 @@
13581360
7BC01A3F241F40AB00BC7C55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
13591361
7BC707F127290ACB002817AD /* SessionCallManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionCallManager.swift; sourceTree = "<group>"; };
13601362
7BCD116B27016062006330F1 /* WebRTCSession+DataChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WebRTCSession+DataChannel.swift"; sourceTree = "<group>"; };
1361-
7BD477A727EC39F5004E2822 /* Atomic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Atomic.swift; sourceTree = "<group>"; };
13621363
7BD687D02A5D0D1200D8E455 /* MessageInfoScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageInfoScreen.swift; sourceTree = "<group>"; };
13631364
7BD687D22A5D283200D8E455 /* build_libSession_util.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_libSession_util.sh; sourceTree = "<group>"; };
13641365
7BDCFC0424206E7300641C39 /* SessionNotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SessionNotificationServiceExtension.entitlements; sourceTree = "<group>"; };
@@ -1945,6 +1946,9 @@
19451946
FD96F3A629DBD43D00401309 /* MockJobRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockJobRunner.swift; sourceTree = "<group>"; };
19461947
FD97B23F2A3FEB050027DD57 /* ARC4RandomNumberGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ARC4RandomNumberGenerator.swift; sourceTree = "<group>"; };
19471948
FD97B2412A3FEBF30027DD57 /* UnreadMarkerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnreadMarkerCell.swift; sourceTree = "<group>"; };
1949+
FD99D0862D0FA72E005D2E15 /* ThreadSafe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadSafe.swift; sourceTree = "<group>"; };
1950+
FD99D08F2D10E718005D2E15 /* NSCache+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSCache+Utilities.swift"; sourceTree = "<group>"; };
1951+
FD99D0912D10F5EB005D2E15 /* ThreadSafeSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadSafeSpec.swift; sourceTree = "<group>"; };
19481952
FD9AECA42AAA9609009B3406 /* NotificationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationError.swift; sourceTree = "<group>"; };
19491953
FD9B30F2293EA0BF008DEE3E /* BatchResponseSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatchResponseSpec.swift; sourceTree = "<group>"; };
19501954
FD9BDDF82A5D2294005F1EBC /* libSessionUtil.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSessionUtil.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1994,7 +1998,6 @@
19941998
FDC4381F27B36ADC00C60D73 /* SOGSEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SOGSEndpoint.swift; sourceTree = "<group>"; };
19951999
FDC4382E27B383AF00C60D73 /* LegacyPushServerResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyPushServerResponse.swift; sourceTree = "<group>"; };
19962000
FDC4383727B3863200C60D73 /* AppVersionResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppVersionResponse.swift; sourceTree = "<group>"; };
1997-
FDC4383D27B4708600C60D73 /* Atomic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Atomic.swift; sourceTree = "<group>"; };
19982001
FDC4385C27B4C18900C60D73 /* Room.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Room.swift; sourceTree = "<group>"; };
19992002
FDC4385E27B4C4A200C60D73 /* PinnedMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinnedMessage.swift; sourceTree = "<group>"; };
20002003
FDC4386227B4D94E00C60D73 /* SOGSMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SOGSMessage.swift; sourceTree = "<group>"; };
@@ -2704,11 +2707,9 @@
27042707
children = (
27052708
947AD68F2C8968FF000B2730 /* Constants.swift */,
27062709
FD428B182B4B576F006D0888 /* AppContext.swift */,
2707-
7BD477A727EC39F5004E2822 /* Atomic.swift */,
27082710
FDC438CC27BC641200C60D73 /* Set+Utilities.swift */,
27092711
7BAF54D527ACD0E2003D12F8 /* ReusableView.swift */,
27102712
C3C2A5D12553860800C340D1 /* Array+Utilities.swift */,
2711-
FDC4383D27B4708600C60D73 /* Atomic.swift */,
27122713
C33FDAA8255A57FF00E217F9 /* BuildConfiguration.swift */,
27132714
B8F5F58225EC94A6003BF8D4 /* Collection+Utilities.swift */,
27142715
FD23CE2F2A67B8820000B97C /* Caches.swift */,
@@ -2720,6 +2721,7 @@
27202721
B8BC00BF257D90E30032E807 /* General.swift */,
27212722
C3C2A5CE2553860700C340D1 /* Logging.swift */,
27222723
C33FDAFD255A580600E217F9 /* LRUCache.swift */,
2724+
FD99D08F2D10E718005D2E15 /* NSCache+Utilities.swift */,
27232725
C33FDA7A255A57FB00E217F9 /* NSRegularExpression+SSK.swift */,
27242726
C352A3762557859C00338F3E /* NSTimer+Proxying.h */,
27252727
C352A36C2557858D00338F3E /* NSTimer+Proxying.m */,
@@ -3648,6 +3650,7 @@
36483650
FDF222082818D2B0000A4995 /* NSAttributedString+Utilities.swift */,
36493651
FDC0F0032BFECE12002CBFB9 /* TimeUnit.swift */,
36503652
FD8ECF912938552800C0D1BB /* Threading.swift */,
3653+
FD99D0862D0FA72E005D2E15 /* ThreadSafe.swift */,
36513654
FD8ECF93293856AF00C0D1BB /* Randomness.swift */,
36523655
FD1936402ACA7BD8004BCF0F /* Result+Utilities.swift */,
36533656
FD29598C2A43BC0B00888A17 /* Version.swift */,
@@ -4566,6 +4569,7 @@
45664569
FDFBB7532A2023EB00CA7350 /* BencodeDecoderSpec.swift */,
45674570
FD6A391C2C2A99DF00762359 /* BencodeEncoderSpec.swift */,
45684571
FD6A391E2C2A99EF00762359 /* BencodeResponseSpec.swift */,
4572+
FD99D0912D10F5EB005D2E15 /* ThreadSafeSpec.swift */,
45694573
FD29598F2A43BE5F00888A17 /* VersionSpec.swift */,
45704574
);
45714575
path = Utilities;
@@ -5811,6 +5815,7 @@
58115815
FD6A38F72C2A6C0100762359 /* CryptoError.swift in Sources */,
58125816
FDE658A329418E2F00A33BC1 /* KeyPair.swift in Sources */,
58135817
FD5931AB2A8DCB0A0040147D /* ScopeAdapter+Utilities.swift in Sources */,
5818+
FD99D0872D0FA731005D2E15 /* ThreadSafe.swift in Sources */,
58145819
FD37E9FF28A5F2CD003AE748 /* Configuration.swift in Sources */,
58155820
FDB7400B28EB99A70094D718 /* TimeInterval+Utilities.swift in Sources */,
58165821
FD09797D27FBDB2000936362 /* Notification+Utilities.swift in Sources */,
@@ -5839,7 +5844,6 @@
58395844
C32C5DDB256DD9FF003C73A2 /* ContentProxy.swift in Sources */,
58405845
C3A71F892558BA9F0043A11F /* Mnemonic.swift in Sources */,
58415846
B8F5F58325EC94A6003BF8D4 /* Collection+Utilities.swift in Sources */,
5842-
7BD477A827EC39F5004E2822 /* Atomic.swift in Sources */,
58435847
FD7F748A2BB298A8006DDFD8 /* JSONDecoder+Utilities.swift in Sources */,
58445848
B8BC00C0257D90E30032E807 /* General.swift in Sources */,
58455849
FD7F74782BB27742006DDFD8 /* BatchRequest.swift in Sources */,
@@ -5874,6 +5878,7 @@
58745878
FD7115FC28C8155800B47552 /* Publisher+Utilities.swift in Sources */,
58755879
FD6A39042C2A8C0300762359 /* CGFloat+Utilities.swift in Sources */,
58765880
C32C5A48256DB8F0003C73A2 /* BuildConfiguration.swift in Sources */,
5881+
FD99D0902D10E71B005D2E15 /* NSCache+Utilities.swift in Sources */,
58775882
FDF84881294059F5007DCAE5 /* ResponseInfo.swift in Sources */,
58785883
FD17D7BF27F51F8200122BE0 /* ColumnExpressible.swift in Sources */,
58795884
FD6A39282C2AB2AA00762359 /* CGSize+Utilities.swift in Sources */,
@@ -6386,6 +6391,7 @@
63866391
buildActionMask = 2147483647;
63876392
files = (
63886393
FD2AAAF228ED57B500A49611 /* SynchronousStorage.swift in Sources */,
6394+
FD99D0922D10F5EE005D2E15 /* ThreadSafeSpec.swift in Sources */,
63896395
FD078E4927E02576000769AF /* CommonMockedExtensions.swift in Sources */,
63906396
FD83B9BF27CF2294005E1583 /* TestConstants.swift in Sources */,
63916397
FDFBB7542A2023EB00CA7350 /* BencodeDecoderSpec.swift in Sources */,
@@ -7677,7 +7683,7 @@
76777683
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
76787684
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
76797685
CODE_SIGN_IDENTITY = "iPhone Developer";
7680-
CURRENT_PROJECT_VERSION = 517;
7686+
CURRENT_PROJECT_VERSION = 519;
76817687
ENABLE_BITCODE = NO;
76827688
ENABLE_STRICT_OBJC_MSGSEND = YES;
76837689
ENABLE_TESTABILITY = YES;
@@ -7714,7 +7720,7 @@
77147720
GCC_WARN_UNUSED_VARIABLE = YES;
77157721
HEADER_SEARCH_PATHS = "";
77167722
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
7717-
MARKETING_VERSION = 2.8.4;
7723+
MARKETING_VERSION = 2.8.5;
77187724
ONLY_ACTIVE_ARCH = YES;
77197725
OTHER_CFLAGS = (
77207726
"-fobjc-arc-exceptions",
@@ -7756,7 +7762,7 @@
77567762
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
77577763
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
77587764
CODE_SIGN_IDENTITY = "iPhone Distribution";
7759-
CURRENT_PROJECT_VERSION = 517;
7765+
CURRENT_PROJECT_VERSION = 519;
77607766
ENABLE_BITCODE = NO;
77617767
ENABLE_STRICT_OBJC_MSGSEND = YES;
77627768
GCC_NO_COMMON_BLOCKS = YES;
@@ -7788,7 +7794,7 @@
77887794
GCC_WARN_UNUSED_VARIABLE = YES;
77897795
HEADER_SEARCH_PATHS = "";
77907796
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
7791-
MARKETING_VERSION = 2.8.4;
7797+
MARKETING_VERSION = 2.8.5;
77927798
ONLY_ACTIVE_ARCH = NO;
77937799
OTHER_CFLAGS = (
77947800
"-DNS_BLOCK_ASSERTIONS=1",

Session/Calls/Call Management/SessionCallManager.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
106106
}
107107

108108
public func reportIncomingCall(_ call: CurrentCallProtocol, callerName: String, completion: @escaping (Error?) -> Void) {
109+
// If CallKit isn't supported then we don't have anything to report the call to
110+
guard Preferences.isCallKitSupported else {
111+
UserDefaults.sharedLokiProject?[.isCallOngoing] = true
112+
UserDefaults.sharedLokiProject?[.lastCallPreOffer] = Date()
113+
completion(nil)
114+
return
115+
}
116+
109117
// Construct a CXCallUpdate describing the incoming call, including the caller.
110118
let update = CXCallUpdate()
111119
update.localizedCallerName = callerName

Session/Calls/Views & Modals/IncomingCallBanner.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate {
104104

105105
private func setUpViewHierarchy() {
106106
self.clipsToBounds = true
107-
self.layer.cornerRadius = Values.largeSpacing
108-
self.set(.height, to: 100)
107+
self.layer.cornerRadius = 16
108+
self.set(.height, to: 80)
109109

110110
addSubview(backgroundView)
111111
backgroundView.pin(to: self)
@@ -125,8 +125,8 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate {
125125
stackView.spacing = Values.largeSpacing
126126
self.addSubview(stackView)
127127

128-
stackView.center(.vertical, in: self)
129-
stackView.set(.width, to: .width, of: self, withOffset: Values.mediumSpacing)
128+
stackView.center(in: self)
129+
stackView.set(.width, to: .width, of: self, withOffset: -Values.mediumSpacing)
130130
}
131131

132132
private func setUpGestureRecognizers() {
@@ -222,8 +222,9 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate {
222222
window.addSubview(self)
223223

224224
let topMargin = window.safeAreaInsets.top - Values.smallSpacing
225-
self.set(.width, to: .width, of: window, withOffset: Values.smallSpacing)
225+
self.set(.width, to: .width, of: window, withOffset: -Values.smallSpacing)
226226
self.pin(.top, to: .top, of: window, withInset: topMargin)
227+
self.center(.horizontal, in: window)
227228

228229
UIView.animate(withDuration: 0.5, delay: 0, options: [], animations: {
229230
self.alpha = 1.0

Session/Calls/WebRTC/WebRTCSession.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
158158
SNLog("[Calls] Sending offer message.")
159159
let uuid: String = self.uuid
160160
let mediaConstraints: RTCMediaConstraints = mediaConstraints(isRestartingICEConnection)
161-
let dependencies: Dependencies = self.dependencies
162161

163162
return Deferred {
164-
Future<Void, Error> { [weak self] resolver in
163+
Future<Void, Error> { [weak self, dependencies = self.dependencies] resolver in
165164
self?.peerConnection?.offer(for: mediaConstraints) { sdp, error in
166165
guard error == nil else { return }
167166

@@ -221,7 +220,6 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
221220
SNLog("[Calls] Sending answer message.")
222221
let uuid: String = self.uuid
223222
let mediaConstraints: RTCMediaConstraints = mediaConstraints(false)
224-
let dependencies: Dependencies = self.dependencies
225223

226224
return dependencies.storage
227225
.readPublisher { db -> SessionThread in
@@ -231,7 +229,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
231229

232230
return thread
233231
}
234-
.flatMap { [weak self] thread in
232+
.flatMap { [weak self, dependencies = self.dependencies] thread in
235233
Future<Void, Error> { resolver in
236234
self?.peerConnection?.answer(for: mediaConstraints) { [weak self] sdp, error in
237235
if let error = error {
@@ -303,13 +301,12 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
303301
let candidates: [RTCIceCandidate] = self.queuedICECandidates
304302
let uuid: String = self.uuid
305303
let contactSessionId: String = self.contactSessionId
306-
let dependencies: Dependencies = self.dependencies
307304

308305
// Empty the queue
309306
self.queuedICECandidates.removeAll()
310307

311308
dependencies.storage
312-
.writePublisher { db in
309+
.writePublisher { [dependencies = self.dependencies] db in
313310
guard let thread: SessionThread = try SessionThread.fetchOne(db, id: contactSessionId) else {
314311
throw WebRTCSessionError.noThread
315312
}
@@ -341,7 +338,9 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
341338
)
342339
}
343340
.subscribe(on: DispatchQueue.global(qos: .userInitiated))
344-
.flatMap { MessageSender.sendImmediate(data: $0, using: dependencies) }
341+
.flatMap { [dependencies = self.dependencies] sendData in
342+
MessageSender.sendImmediate(data: sendData, using: dependencies)
343+
}
345344
.sinkUntilComplete()
346345
}
347346

Session/Conversations/ConversationSearch.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ protocol SearchResultsBarDelegate: AnyObject {
134134
}
135135

136136
public final class SearchResultsBar: UIView {
137-
private var readConnection: Atomic<Database?> = Atomic(nil)
138-
private var results: Atomic<[Interaction.TimestampInfo]?> = Atomic(nil)
137+
@ThreadSafe private var hasResults: Bool = false
138+
@ThreadSafeObject private var results: [Interaction.TimestampInfo] = []
139+
@ThreadSafeObject private var readConnection: Database? = nil
139140

140141
var currentIndex: Int?
141142
weak var resultsBarDelegate: SearchResultsBarDelegate?
@@ -250,7 +251,7 @@ public final class SearchResultsBar: UIView {
250251
// MARK: - Actions
251252

252253
@objc public func handleUpButtonTapped() {
253-
guard let results: [Interaction.TimestampInfo] = results.wrappedValue else { return }
254+
guard hasResults else { return }
254255
guard let currentIndex: Int = currentIndex else { return }
255256
guard currentIndex + 1 < results.count else { return }
256257

@@ -261,7 +262,7 @@ public final class SearchResultsBar: UIView {
261262
}
262263

263264
@objc public func handleDownButtonTapped() {
264-
guard let results: [Interaction.TimestampInfo] = results.wrappedValue else { return }
265+
guard hasResults else { return }
265266
guard let currentIndex: Int = currentIndex, currentIndex > 0 else { return }
266267

267268
let newIndex = currentIndex - 1
@@ -274,7 +275,7 @@ public final class SearchResultsBar: UIView {
274275

275276
/// This method will be called within a DB read block
276277
func willStartSearching(readConnection: Database) {
277-
let hasNoExistingResults: Bool = (self.results.wrappedValue?.isEmpty != false)
278+
let hasNoExistingResults: Bool = hasResults
278279

279280
DispatchQueue.main.async { [weak self] in
280281
if hasNoExistingResults {
@@ -284,8 +285,8 @@ public final class SearchResultsBar: UIView {
284285
self?.startLoading()
285286
}
286287

287-
self.readConnection.wrappedValue?.interrupt()
288-
self.readConnection.mutate { $0 = readConnection }
288+
self.readConnection?.interrupt()
289+
self._readConnection.set(to: readConnection)
289290
}
290291

291292
func updateResults(results: [Interaction.TimestampInfo]?, visibleItemIds: [Int64]?) {
@@ -308,8 +309,9 @@ public final class SearchResultsBar: UIView {
308309
return 0
309310
}()
310311

311-
self.readConnection.mutate { $0 = nil }
312-
self.results.mutate { $0 = results }
312+
self._readConnection.set(to: nil)
313+
self._results.performUpdate { _ in (results ?? []) }
314+
self.hasResults = (results != nil)
313315

314316
updateBarItems()
315317

@@ -319,7 +321,7 @@ public final class SearchResultsBar: UIView {
319321
}
320322

321323
func updateBarItems() {
322-
guard let results: [Interaction.TimestampInfo] = results.wrappedValue else {
324+
guard hasResults else {
323325
label.text = ""
324326
downButton.isEnabled = false
325327
upButton.isEnabled = false

0 commit comments

Comments
 (0)