-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Problem
SharedState class in ArkavoApp.swift (lines 946-1031) is a god object mixing unrelated concerns with an untyped state storage dictionary.
Current Implementation
class SharedState: ObservableObject {
@Published var selectedTab: Tab = .home
@Published var selectedCreatorPublicID: Data?
@Published var isOfflineMode: Bool = false
@Published var registrationError: String?
@Published var isAwaiting: Bool = false
// ... 10+ more @Published properties
private var stateStorage: [String: Any] = [:] // Untyped bag!
func setState(_ value: Any, forKey key: String) {
stateStorage[key] = value
}
}Issues
- Mixed concerns: Tab selection, offline mode, errors, registration all in one class
- Untyped storage:
[String: Any]loses all type safety - Implicit dependencies: Views access random keys without compile-time checking
- Debugging difficulty: State changes hard to trace
- Testing difficulty: Cannot mock specific state
Proposed Solution
// Separate, focused state objects
class NavigationState: ObservableObject {
@Published var selectedTab: Tab = .home
}
class ConnectionState: ObservableObject {
@Published var isOffline: Bool = false
@Published var connectionError: Error?
}
class RegistrationState: ObservableObject {
@Published var step: RegistrationStep = .initial
@Published var error: RegistrationError?
}
// Inject only what each view needsAcceptance Criteria
- SharedState removed entirely
- Feature-specific state objects created
- No
[String: Any]untyped storage - Each state object has clear ownership
- Views inject only the state they need