Replace the ServiceLocator with direct dependency injection (#5548)

Removes the ServiceLocator singleton and instead directly injects the dependencies it was holding for more control over instantiation of the various component subtrees and better visibility over how they're being used.
This commit is contained in:
Michael
2026-05-14 01:45:49 -05:00
committed by GitHub
parent f70182d09a
commit ff5dcb040d
108 changed files with 971 additions and 729 deletions
@@ -18,7 +18,13 @@ final class RoomFlowCoordinatorTests {
var roomFlowCoordinator: RoomFlowCoordinator!
var navigationStackCoordinator: NavigationStackCoordinator!
var cancellables = Set<AnyCancellable>()
private let appSettings: AppSettings
init() {
appSettings = AppSettings()
}
deinit {
AppSettings.resetAllSettings()
}
@@ -236,7 +242,7 @@ final class RoomFlowCoordinatorTests {
@Test
func threadedEventRoutes() async throws {
ServiceLocator.shared.settings.threadsEnabled = true
appSettings.threadsEnabled = true
setupRoomFlowCoordinator()
// Navigate directly to the threaded event
@@ -479,13 +485,13 @@ final class RoomFlowCoordinatorTests {
bugReportService: BugReportServiceMock(.init()),
elementCallService: ElementCallServiceMock(.init()),
timelineControllerFactory: timelineControllerFactory,
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
emojiProvider: EmojiProvider(appSettings: appSettings),
linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock.default,
appSettings: ServiceLocator.shared.settings,
appSettings: appSettings,
appHooks: AppHooks(),
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController,
analytics: .mock(settings: appSettings),
userIndicatorController: UserIndicatorControllerMock.default,
notificationManager: NotificationManagerMock(),
stateMachineFactory: StateMachineFactory())