mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
6eeb0ec7ac
Copy tweak Added a toast when copying the sessionId or group URL (fixes to the toast UI as well) Fixed the new conversation screen styling Fixed the styling of the various attachment screens Updated the buttons on the attachment screen to behave like the input view buttons Removed the old OWSNavigationBar and OWSNavigationController (logic was buggy and not actually needed in most cases)
94 lines
3 KiB
Swift
94 lines
3 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import SessionUtilitiesKit
|
|
import SessionMessagingKit
|
|
|
|
public struct SessionApp {
|
|
static let homeViewController: Atomic<HomeVC?> = Atomic(nil)
|
|
|
|
// MARK: - View Convenience Methods
|
|
|
|
public static func presentConversation(for threadId: String, action: ConversationViewModel.Action = .none, animated: Bool) {
|
|
let maybeThreadInfo: (thread: SessionThread, isMessageRequest: Bool)? = Storage.shared.write { db in
|
|
let thread: SessionThread = try SessionThread.fetchOrCreate(db, id: threadId, variant: .contact)
|
|
|
|
return (thread, thread.isMessageRequest(db))
|
|
}
|
|
|
|
guard
|
|
let variant: SessionThread.Variant = maybeThreadInfo?.thread.variant,
|
|
let isMessageRequest: Bool = maybeThreadInfo?.isMessageRequest
|
|
else { return }
|
|
|
|
self.presentConversation(
|
|
for: threadId,
|
|
threadVariant: variant,
|
|
isMessageRequest: isMessageRequest,
|
|
action: action,
|
|
focusInteractionId: nil,
|
|
animated: animated
|
|
)
|
|
}
|
|
|
|
public static func presentConversation(
|
|
for threadId: String,
|
|
threadVariant: SessionThread.Variant,
|
|
isMessageRequest: Bool,
|
|
action: ConversationViewModel.Action,
|
|
focusInteractionId: Int64?,
|
|
animated: Bool
|
|
) {
|
|
guard Thread.isMainThread else {
|
|
DispatchQueue.main.async {
|
|
self.presentConversation(
|
|
for: threadId,
|
|
threadVariant: threadVariant,
|
|
isMessageRequest: isMessageRequest,
|
|
action: action,
|
|
focusInteractionId: focusInteractionId,
|
|
animated: animated
|
|
)
|
|
}
|
|
return
|
|
}
|
|
|
|
homeViewController.wrappedValue?.show(
|
|
threadId,
|
|
variant: threadVariant,
|
|
isMessageRequest: isMessageRequest,
|
|
with: action,
|
|
focusedInteractionId: focusInteractionId,
|
|
animated: animated
|
|
)
|
|
}
|
|
|
|
// MARK: - Functions
|
|
|
|
public static func resetAppData(onReset: (() -> ())? = nil) {
|
|
// This _should_ be wiped out below.
|
|
Logger.error("")
|
|
DDLog.flushLog()
|
|
|
|
Storage.resetAllStorage()
|
|
ProfileManager.resetProfileStorage()
|
|
Attachment.resetAttachmentStorage()
|
|
AppEnvironment.shared.notificationPresenter.clearAllNotifications()
|
|
|
|
onReset?()
|
|
exit(0)
|
|
}
|
|
|
|
public static func showHomeView() {
|
|
guard Thread.isMainThread else {
|
|
DispatchQueue.main.async {
|
|
self.showHomeView()
|
|
}
|
|
return
|
|
}
|
|
|
|
let homeViewController: HomeVC = HomeVC()
|
|
let navController: UINavigationController = StyledNavigationController(rootViewController: homeViewController)
|
|
(UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController = navController
|
|
}
|
|
}
|