-
-
Notifications
You must be signed in to change notification settings - Fork 37
Adds "Share Vault" option to vault detail settings. #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 4 commits
ad78d19
a317f83
3b313d5
727673c
1922f76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // | ||
| // ShareVaultCoordinator.swift | ||
| // Cryptomator | ||
| // | ||
| // Created by Majid Achhoud on 30.10.25. | ||
| // Copyright © 2025 Skymatic GmbH. All rights reserved. | ||
| // | ||
|
|
||
| import CryptomatorCloudAccessCore | ||
| import CryptomatorCommonCore | ||
| import UIKit | ||
|
|
||
| class ShareVaultCoordinator: Coordinator { | ||
| weak var parentCoordinator: Coordinator? | ||
| lazy var childCoordinators = [Coordinator]() | ||
| var navigationController: UINavigationController | ||
| private let vaultInfo: VaultInfo | ||
|
|
||
| init(vaultInfo: VaultInfo, navigationController: UINavigationController) { | ||
| self.vaultInfo = vaultInfo | ||
| self.navigationController = navigationController | ||
| } | ||
|
|
||
| func start() { | ||
| let viewModel: ShareVaultViewModel | ||
| if vaultInfo.vaultConfigType == .hub, let hubURL = extractHubVaultURL() { | ||
| viewModel = ShareVaultViewModel(type: .hub(hubURL)) | ||
| } else { | ||
| viewModel = ShareVaultViewModel(type: .normal) | ||
| } | ||
| let shareVaultViewController = ShareVaultViewController(viewModel: viewModel) | ||
| shareVaultViewController.coordinator = self | ||
| navigationController.pushViewController(shareVaultViewController, animated: true) | ||
| } | ||
|
|
||
| private func extractHubVaultURL() -> URL? { | ||
| guard let cachedVault = try? VaultDBCache().getCachedVault(withVaultUID: vaultInfo.vaultUID), | ||
| let vaultConfigToken = cachedVault.vaultConfigToken, | ||
| let vaultConfig = try? UnverifiedVaultConfig(token: vaultConfigToken), | ||
| let hubConfig = vaultConfig.allegedHubConfig else { | ||
| return nil | ||
| } | ||
|
|
||
| // Extract base Hub URL | ||
| let apiBaseURL: URL? | ||
| if let apiBaseUrl = hubConfig.apiBaseUrl { | ||
| apiBaseURL = URL(string: apiBaseUrl) | ||
| } else if let deviceResourceURL = URL(string: hubConfig.devicesResourceUrl) { | ||
| apiBaseURL = deviceResourceURL.deletingLastPathComponent() | ||
| } else { | ||
| apiBaseURL = nil | ||
| } | ||
|
|
||
| return apiBaseURL?.deletingLastPathComponent() | ||
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling Hub URL extraction failures more explicitly.
When
vaultInfo.vaultConfigType == .hubbutextractHubVaultURL()returnsnil, the code silently falls back to.normaltype. This could confuse users who expect Hub-specific features. Consider:🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobihagemann I see three ways to fix this:
Option 1 - it's the clearest for users. Alternatively, is this just an edge case that's unlikely to happen in practice? In the worst case, users would currently just see our Hub marketing page instead of their actual Hub instance, which would be confusing but not breaking anything. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's go with option 1. It's totally an edge case and shouldn't happen, but you never know what we're changing in the future. 😄