Skip to content

Commit 78a33f1

Browse files
authored
Merge pull request #1017 from oxen-io/dev
Release 1.7.3
2 parents ecfa3d4 + f07d0ba commit 78a33f1

File tree

16 files changed

+349
-214
lines changed

16 files changed

+349
-214
lines changed

Session.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -7673,7 +7673,7 @@
76737673
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
76747674
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
76757675
CODE_SIGN_IDENTITY = "iPhone Developer";
7676-
CURRENT_PROJECT_VERSION = 478;
7676+
CURRENT_PROJECT_VERSION = 483;
76777677
ENABLE_BITCODE = NO;
76787678
ENABLE_STRICT_OBJC_MSGSEND = YES;
76797679
ENABLE_TESTABILITY = YES;
@@ -7710,7 +7710,7 @@
77107710
GCC_WARN_UNUSED_VARIABLE = YES;
77117711
HEADER_SEARCH_PATHS = "";
77127712
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
7713-
MARKETING_VERSION = 2.7.2;
7713+
MARKETING_VERSION = 2.7.3;
77147714
ONLY_ACTIVE_ARCH = YES;
77157715
OTHER_CFLAGS = (
77167716
"-fobjc-arc-exceptions",
@@ -7751,7 +7751,7 @@
77517751
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
77527752
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
77537753
CODE_SIGN_IDENTITY = "iPhone Distribution";
7754-
CURRENT_PROJECT_VERSION = 478;
7754+
CURRENT_PROJECT_VERSION = 483;
77557755
ENABLE_BITCODE = NO;
77567756
ENABLE_STRICT_OBJC_MSGSEND = YES;
77577757
GCC_NO_COMMON_BLOCKS = YES;
@@ -7783,7 +7783,7 @@
77837783
GCC_WARN_UNUSED_VARIABLE = YES;
77847784
HEADER_SEARCH_PATHS = "";
77857785
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
7786-
MARKETING_VERSION = 2.7.2;
7786+
MARKETING_VERSION = 2.7.3;
77877787
ONLY_ACTIVE_ARCH = NO;
77887788
OTHER_CFLAGS = (
77897789
"-DNS_BLOCK_ASSERTIONS=1",

Session/Calls/Call Management/SessionCallManager.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
205205
// Stop all jobs except for message sending and when completed suspend the database
206206
JobRunner.stopAndClearPendingJobs(exceptForVariant: .messageSend, using: dependencies) { _ in
207207
LibSession.suspendNetworkAccess()
208-
Storage.suspendDatabaseAccess()
208+
Storage.suspendDatabaseAccess(using: dependencies)
209209
Log.flush()
210210
}
211211
}

Session/Meta/AppDelegate.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
147147
/// Apple's documentation on the matter)
148148
UNUserNotificationCenter.current().delegate = self
149149

150-
Storage.resumeDatabaseAccess()
150+
Storage.resumeDatabaseAccess(using: dependencies)
151151
LibSession.resumeNetworkAccess()
152152

153153
// Reset the 'startTime' (since it would be invalid from the last launch)
@@ -209,10 +209,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
209209
stopPollers(shouldStopUserPoller: !self.hasCallOngoing())
210210

211211
// Stop all jobs except for message sending and when completed suspend the database
212-
JobRunner.stopAndClearPendingJobs(exceptForVariant: .messageSend, using: dependencies) { neededBackgroundProcessing in
212+
JobRunner.stopAndClearPendingJobs(exceptForVariant: .messageSend, using: dependencies) { [dependencies] neededBackgroundProcessing in
213213
if !self.hasCallOngoing() && (!neededBackgroundProcessing || Singleton.hasAppContext && Singleton.appContext.isInBackground) {
214214
LibSession.suspendNetworkAccess()
215-
Storage.suspendDatabaseAccess()
215+
Storage.suspendDatabaseAccess(using: dependencies)
216216
Log.info("[AppDelegate] completed network and database shutdowns.")
217217
Log.flush()
218218
}
@@ -238,7 +238,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
238238
UserDefaults.sharedLokiProject?[.isMainAppActive] = true
239239

240240
// FIXME: Seems like there are some discrepancies between the expectations of how the iOS lifecycle methods work, we should look into them and ensure the code behaves as expected (in this case there were situations where these two wouldn't get called when returning from the background)
241-
Storage.resumeDatabaseAccess()
241+
Storage.resumeDatabaseAccess(using: dependencies)
242242
LibSession.resumeNetworkAccess()
243243

244244
ensureRootViewController(calledFrom: .didBecomeActive)
@@ -288,7 +288,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
288288
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
289289
Log.appResumedExecution()
290290
Log.info("Starting background fetch.")
291-
Storage.resumeDatabaseAccess()
291+
Storage.resumeDatabaseAccess(using: dependencies)
292292
LibSession.resumeNetworkAccess()
293293

294294
let queue: DispatchQueue = .global(qos: .userInitiated)
@@ -302,7 +302,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
302302
let cancelTimer: Timer = Timer.scheduledTimerOnMainThread(
303303
withTimeInterval: (application.backgroundTimeRemaining - 5),
304304
repeats: false
305-
) { [poller] timer in
305+
) { [poller, dependencies] timer in
306306
timer.invalidate()
307307

308308
guard cancellable != nil else { return }
@@ -312,7 +312,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
312312

313313
if Singleton.hasAppContext && Singleton.appContext.isInBackground {
314314
LibSession.suspendNetworkAccess()
315-
Storage.suspendDatabaseAccess()
315+
Storage.suspendDatabaseAccess(using: dependencies)
316316
Log.flush()
317317
}
318318

@@ -338,7 +338,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
338338

339339
if Singleton.hasAppContext && Singleton.appContext.isInBackground {
340340
LibSession.suspendNetworkAccess()
341-
Storage.suspendDatabaseAccess()
341+
Storage.suspendDatabaseAccess(using: dependencies)
342342
Log.flush()
343343
}
344344

@@ -934,7 +934,7 @@ private enum StartupError: Error {
934934

935935
var name: String {
936936
switch self {
937-
case .databaseError(StorageError.startupFailed), .databaseError(DatabaseError.SQLITE_LOCKED):
937+
case .databaseError(StorageError.startupFailed), .databaseError(DatabaseError.SQLITE_LOCKED), .databaseError(StorageError.databaseSuspended):
938938
return "Database startup failed"
939939

940940
case .databaseError(StorageError.migrationNoLongerSupported): return "Unsupported version"
@@ -946,7 +946,7 @@ private enum StartupError: Error {
946946

947947
var message: String {
948948
switch self {
949-
case .databaseError(StorageError.startupFailed), .databaseError(DatabaseError.SQLITE_LOCKED):
949+
case .databaseError(StorageError.startupFailed), .databaseError(DatabaseError.SQLITE_LOCKED), .databaseError(StorageError.databaseSuspended):
950950
return "DATABASE_STARTUP_FAILED".localized()
951951

952952
case .databaseError(StorageError.migrationNoLongerSupported):

Session/Meta/MainAppContext.swift

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ final class MainAppContext: AppContext {
2323
return result
2424
}
2525
var frontmostViewController: UIViewController? { UIApplication.shared.frontmostViewControllerIgnoringAlerts }
26+
var backgroundTimeRemaining: TimeInterval { UIApplication.shared.backgroundTimeRemaining }
2627

2728
var mainWindow: UIWindow?
2829
var wasWokenUpByPushNotification: Bool = false

Session/Meta/SessionApp.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ public struct SessionApp {
126126
Log.info("Data Reset Complete.")
127127
Log.flush()
128128

129-
exit(0)
129+
/// Wait until the next run loop to kill the app (hoping to avoid a crash due to the connection closes
130+
/// triggering logs)
131+
DispatchQueue.main.async {
132+
exit(0)
133+
}
130134
}
131135

132136
public static func showHomeView(using dependencies: Dependencies) {

Session/Notifications/PushRegistrationManager.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ public enum PushRegistrationError: Error {
290290
return
291291
}
292292

293-
Storage.resumeDatabaseAccess()
293+
// FIXME: Initialise the `PushRegistrationManager` with a dependencies instance
294+
let dependencies: Dependencies = Dependencies()
295+
296+
Storage.resumeDatabaseAccess(using: dependencies)
294297
LibSession.resumeNetworkAccess()
295298

296299
let maybeCall: SessionCall? = Storage.shared.write { db in

Session/Settings/PrivacySettingsViewModel.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ class PrivacySettingsViewModel: SessionTableViewModel, NavigationItemSource, Nav
307307
showCondition: .disabled,
308308
confirmTitle: "continue_2".localized(),
309309
confirmAccessibility: Accessibility(identifier: "Enable"),
310-
confirmStyle: .textPrimary,
310+
confirmStyle: .danger,
311+
cancelStyle: .alert_text,
311312
onConfirm: { _ in Permissions.requestMicrophonePermissionIfNeeded() }
312313
),
313314
onTap: {

SessionNotificationServiceExtension/NotificationServiceExtension.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
5151
}
5252

5353
// Perform main setup
54-
Storage.resumeDatabaseAccess()
54+
Storage.resumeDatabaseAccess(using: dependencies)
5555
DispatchQueue.main.sync {
5656
self.setUpIfNecessary() { [weak self] in
5757
self?.handleNotification(notificationContent, isPerformingResetup: false)
@@ -415,7 +415,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
415415

416416
Log.info(handledNotification ? "Completed after handling notification." : "Completed silently.")
417417
if !isMainAppAndActive {
418-
Storage.suspendDatabaseAccess()
418+
Storage.suspendDatabaseAccess(using: dependencies)
419419
}
420420
Log.flush()
421421

@@ -495,7 +495,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
495495

496496
private func handleFailure(for content: UNMutableNotificationContent, error: NotificationError) {
497497
Log.error("Show generic failure message due to error: \(error).")
498-
Storage.suspendDatabaseAccess()
498+
Storage.suspendDatabaseAccess(using: dependencies)
499499
Log.flush()
500500

501501
content.title = "Session"

SessionShareExtension/ThreadPickerVC.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
111111
// When the thread picker disappears it means the user has left the screen (this will be called
112112
// whether the user has sent the message or cancelled sending)
113113
LibSession.suspendNetworkAccess()
114-
Storage.suspendDatabaseAccess()
114+
Storage.suspendDatabaseAccess(using: viewModel.dependencies)
115115
Log.flush()
116116
}
117117

@@ -240,7 +240,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
240240
shareNavController?.dismiss(animated: true, completion: nil)
241241

242242
ModalActivityIndicatorViewController.present(fromViewController: shareNavController!, canCancel: false, message: "vc_share_sending_message".localized()) { [dependencies = viewModel.dependencies] activityIndicator in
243-
Storage.resumeDatabaseAccess()
243+
Storage.resumeDatabaseAccess(using: dependencies)
244244
LibSession.resumeNetworkAccess()
245245

246246
let swarmPublicKey: String = {
@@ -336,7 +336,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
336336
.sinkUntilComplete(
337337
receiveCompletion: { [weak self] result in
338338
LibSession.suspendNetworkAccess()
339-
Storage.suspendDatabaseAccess()
339+
Storage.suspendDatabaseAccess(using: dependencies)
340340
Log.flush()
341341
activityIndicator.dismiss { }
342342

SessionUtilitiesKit/Database/Models/Identity.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public extension Identity {
142142

143143
static func mnemonic() throws -> String {
144144
let dbIsValid: Bool = Storage.shared.isValid
145-
let dbIsSuspendedUnsafe: Bool = Storage.shared.isSuspendedUnsafe
145+
let dbIsSuspended: Bool = Storage.shared.isSuspended
146146

147147
if let hexEncodedSeed: String = Identity.fetchHexEncodedSeed() {
148148
return Mnemonic.encode(hexEncodedString: hexEncodedSeed)
@@ -153,7 +153,7 @@ public extension Identity {
153153
let hasStoredEdKeyPair: Bool = (Identity.fetchUserEd25519KeyPair() != nil)
154154
let dbStates: [String] = [
155155
"dbIsValid: \(dbIsValid)",
156-
"dbIsSuspendedUnsafe: \(dbIsSuspendedUnsafe)",
156+
"dbIsSuspended: \(dbIsSuspended)",
157157
"storedSeed: false",
158158
"userPublicKey: \(hasStoredPublicKey)",
159159
"userPrivateKey: false",

0 commit comments

Comments
 (0)