Make the remote settings hook usable within the app extensions. (#4342)
This commit is contained in:
@@ -11,11 +11,19 @@ import SwiftUI
|
||||
class ShareExtensionViewController: UIViewController {
|
||||
private static var targetConfiguration: Target.Configuration?
|
||||
private let appSettings: CommonSettingsProtocol = AppSettings()
|
||||
private var appHooks: AppHooks!
|
||||
|
||||
private let keychainController = KeychainController(service: .sessions,
|
||||
accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
|
||||
|
||||
private let hostingController = UIHostingController(rootView: ShareExtensionView())
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
appHooks = AppHooks()
|
||||
appHooks.setUp()
|
||||
|
||||
if Self.targetConfiguration == nil {
|
||||
Self.targetConfiguration = Target.shareExtension.configure(logLevel: appSettings.logLevel,
|
||||
traceLogPacks: appSettings.traceLogPacks,
|
||||
@@ -30,6 +38,14 @@ class ShareExtensionViewController: UIViewController {
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
if let credentials = keychainController.restorationTokens().first {
|
||||
let homeserverURL = credentials.restorationToken.session.homeserverUrl
|
||||
appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: appSettings)
|
||||
} else {
|
||||
// We should really show a different state when there isn't a logged in user, but for now this is fine.
|
||||
MXLog.error("Not logged in, launching app to show the authentication flow.")
|
||||
}
|
||||
|
||||
Task {
|
||||
if let payload = await prepareSharePayload() {
|
||||
await self.openMainApp(payload: payload)
|
||||
|
||||
@@ -6,5 +6,9 @@
|
||||
<array>
|
||||
<string>$(APP_GROUP_IDENTIFIER)</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(KEYCHAIN_ACCESS_GROUP_IDENTIFIER)</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -33,8 +33,9 @@ targets:
|
||||
|
||||
dependencies:
|
||||
- package: MatrixRustSDK
|
||||
- package: Collections
|
||||
- package: Compound
|
||||
- package: Collections
|
||||
- package: KeychainAccess
|
||||
|
||||
info:
|
||||
path: Info.plist
|
||||
@@ -50,9 +51,7 @@ targets:
|
||||
NSExtensionPointIdentifier: com.apple.share-services
|
||||
NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).ShareExtensionViewController
|
||||
NSExtensionAttributes:
|
||||
IntentsSupported: [
|
||||
INSendMessageIntent,
|
||||
]
|
||||
IntentsSupported: [INSendMessageIntent]
|
||||
NSExtensionActivationRule:
|
||||
NSExtensionActivationSupportsFileWithMaxCount: 1
|
||||
NSExtensionActivationSupportsImageWithMaxCount: 1
|
||||
@@ -65,6 +64,8 @@ targets:
|
||||
properties:
|
||||
com.apple.security.application-groups:
|
||||
- $(APP_GROUP_IDENTIFIER)
|
||||
keychain-access-groups:
|
||||
- $(KEYCHAIN_ACCESS_GROUP_IDENTIFIER)
|
||||
|
||||
settings:
|
||||
base:
|
||||
@@ -79,8 +80,16 @@ targets:
|
||||
- path: ../Sources
|
||||
- path: ../SupportingFiles
|
||||
- path: ../../ElementX/Sources/ShareExtension
|
||||
- path: ../../ElementX/Sources/AppHooks/AppHooks.swift
|
||||
- path: ../../ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift
|
||||
- path: ../../ElementX/Sources/AppHooks/Hooks/RemoteSettingsHook.swift
|
||||
- path: ../../Secrets/Secrets.swift
|
||||
- path: ../../ElementX/Sources/Application/Settings
|
||||
- path: ../../ElementX/Sources/Application/TargetConfiguration.swift
|
||||
- path: ../../ElementX/Sources/Services/Keychain/KeychainController.swift
|
||||
- path: ../../ElementX/Sources/Services/Keychain/KeychainControllerProtocol.swift
|
||||
- path: ../../ElementX/Sources/Services/UserSession/RestorationToken.swift
|
||||
- path: ../../ElementX/Sources/Services/UserSession/SessionDirectories.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/Bundle.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/FileManager.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/NSItemProvider.swift
|
||||
|
||||
Reference in New Issue
Block a user