Skip to content
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

GT-2412 Create dependency container for feature favorited tool language settings persistence #2331

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions godtools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@
457FEF032CBEA43B0092E84B /* CYOAPageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457FEF002CBEA43B0092E84B /* CYOAPageViewModel.swift */; };
457FEF042CBEA43B0092E84B /* CYOAPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457FEEFF2CBEA43B0092E84B /* CYOAPageView.swift */; };
4581657626F4DD4D000D660F /* MobileContentRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581657526F4DD4D000D660F /* MobileContentRowView.swift */; };
4581696F2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581696C2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift */; };
458169702CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581696D2CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift */; };
458169712CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581696E2CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift */; };
4581D97F297AD21E00D056D6 /* JsonApiResponseData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581D97E297AD21E00D056D6 /* JsonApiResponseData.swift */; };
4581EAA32BFBE194008115FF /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 4581EAA22BFBE194008115FF /* RealmSwift */; };
4581EAA52BFBE257008115FF /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 4581EAA42BFBE257008115FF /* RealmSwift */; };
Expand Down Expand Up @@ -2306,6 +2309,9 @@
457FEEFF2CBEA43B0092E84B /* CYOAPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CYOAPageView.swift; sourceTree = "<group>"; };
457FEF002CBEA43B0092E84B /* CYOAPageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CYOAPageViewModel.swift; sourceTree = "<group>"; };
4581657526F4DD4D000D660F /* MobileContentRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileContentRowView.swift; sourceTree = "<group>"; };
4581696C2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistUserToolLanguageSettingsDataLayerDependencies.swift; sourceTree = "<group>"; };
4581696D2CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistUserToolLanguageSettingsDiContainer.swift; sourceTree = "<group>"; };
4581696E2CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistUserToolLanguageSettingsDomainLayerDependencies.swift; sourceTree = "<group>"; };
4581D97E297AD21E00D056D6 /* JsonApiResponseData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonApiResponseData.swift; sourceTree = "<group>"; };
45828BC7279CCB5300F6B5F3 /* MobileContentCardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileContentCardView.swift; sourceTree = "<group>"; };
45828BC9279CCB6900F6B5F3 /* MobileContentCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileContentCardViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6714,6 +6720,16 @@
path = ContentRow;
sourceTree = "<group>";
};
4581696B2CDD008400039D03 /* DependencyContainer */ = {
isa = PBXGroup;
children = (
4581696D2CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift */,
4581696C2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift */,
4581696E2CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift */,
);
path = DependencyContainer;
sourceTree = "<group>";
};
4581C58D285A5C7A0078425B /* ToolTraining */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -11327,6 +11343,7 @@
children = (
D4159D572C2CE1D50088A203 /* Data */,
D4159D562C2CE18C0088A203 /* Data-DomainInterface */,
4581696B2CDD008400039D03 /* DependencyContainer */,
D4159D522C2CE0B80088A203 /* Domain */,
);
path = PersistUserToolLanguageSettings;
Expand Down Expand Up @@ -13525,6 +13542,9 @@
D4C2A5642C3090C10035AB4D /* LessonFilterLanguagesInterfaceStringsDomainModel.swift in Sources */,
45E3476A2A49BE230014CCD1 /* FlowDelegate.swift in Sources */,
45D4A6CD29B126BB00DED984 /* MobileContentPagesPage.swift in Sources */,
4581696F2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift in Sources */,
458169702CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift in Sources */,
458169712CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift in Sources */,
4598BD0D2BF7DF6800196463 /* AppleAuthentication+AuthenticationProviderInterface.swift in Sources */,
45677783287DB21F0044AEB2 /* ToolTrainingAnimatedTransitioning.swift in Sources */,
45AD20BB25938F1A00A096A0 /* ObservableValue.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions godtools/App/DependencyContainer/AppDiContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppDiContainer {
let lessonsDiContainer = LessonsFeatureDiContainer(coreDataLayer: dataLayer)
let lessonProgressDiContainer = UserLessonProgressDiContainer(coreDataLayer: dataLayer)
let onboardingDiContainer = OnboardingDiContainer(coreDataLayer: dataLayer)
let persistFavoritedToolLanguageSettingsDiContainer = PersistUserToolLanguageSettingsDiContainer(coreDataLayer: dataLayer)
let shareablesDiContainer: ShareablesDiContainer = ShareablesDiContainer(coreDataLayer: dataLayer)
let shareGodToolsDiContainer = ShareGodToolsDiContainer(coreDataLayer: dataLayer)
let spotlightToolsDiContainer = SpotlightToolsDiContainer(coreDataLayer: dataLayer)
Expand All @@ -71,6 +72,7 @@ class AppDiContainer {
lessons: lessonsDiContainer,
lessonProgress: lessonProgressDiContainer,
onboarding: onboardingDiContainer,
persistFavoritedToolLanguageSettings: persistFavoritedToolLanguageSettingsDiContainer,
shareables: shareablesDiContainer,
shareGodTools: shareGodToolsDiContainer,
spotlightTools: spotlightToolsDiContainer,
Expand Down
4 changes: 3 additions & 1 deletion godtools/App/DependencyContainer/AppFeatureDiContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AppFeatureDiContainer {
let lessons: LessonsFeatureDiContainer
let lessonProgress: UserLessonProgressDiContainer
let onboarding: OnboardingDiContainer
let persistFavoritedToolLanguageSettings: PersistUserToolLanguageSettingsDiContainer
let shareables: ShareablesDiContainer
let shareGodTools: ShareGodToolsDiContainer
let spotlightTools: SpotlightToolsDiContainer
Expand All @@ -33,7 +34,7 @@ class AppFeatureDiContainer {
let toolShortcutLinks: ToolShortcutLinksDiContainer
let tutorial: TutorialFeatureDiContainer

init(account: AccountDiContainer, appLanguage: AppLanguageFeatureDiContainer, dashboard: DashboardDiContainer, downloadToolProgress: DownloadToolProgressFeatureDiContainer, favorites: FavoritesDiContainer, featuredLessons: FeaturedLessonsDiContainer, globalActivity: GlobalActivityDiContainer, learnToShareTool: LearnToShareToolDiContainer, lessonEvaluation: LessonEvaluationFeatureDiContainer, lessonFilter: LessonFilterDiContainer, lessons: LessonsFeatureDiContainer, lessonProgress: UserLessonProgressDiContainer, onboarding: OnboardingDiContainer, shareables: ShareablesDiContainer, shareGodTools: ShareGodToolsDiContainer, spotlightTools: SpotlightToolsDiContainer, toolDetails: ToolDetailsFeatureDiContainer, toolScreenShare: ToolScreenShareFeatureDiContainer, toolSettings: ToolSettingsDiContainer, toolsFilter: ToolsFilterFeatureDiContainer, toolShortcutLinks: ToolShortcutLinksDiContainer, tutorial: TutorialFeatureDiContainer) {
init(account: AccountDiContainer, appLanguage: AppLanguageFeatureDiContainer, dashboard: DashboardDiContainer, downloadToolProgress: DownloadToolProgressFeatureDiContainer, favorites: FavoritesDiContainer, featuredLessons: FeaturedLessonsDiContainer, globalActivity: GlobalActivityDiContainer, learnToShareTool: LearnToShareToolDiContainer, lessonEvaluation: LessonEvaluationFeatureDiContainer, lessonFilter: LessonFilterDiContainer, lessons: LessonsFeatureDiContainer, lessonProgress: UserLessonProgressDiContainer, onboarding: OnboardingDiContainer, persistFavoritedToolLanguageSettings: PersistUserToolLanguageSettingsDiContainer, shareables: ShareablesDiContainer, shareGodTools: ShareGodToolsDiContainer, spotlightTools: SpotlightToolsDiContainer, toolDetails: ToolDetailsFeatureDiContainer, toolScreenShare: ToolScreenShareFeatureDiContainer, toolSettings: ToolSettingsDiContainer, toolsFilter: ToolsFilterFeatureDiContainer, toolShortcutLinks: ToolShortcutLinksDiContainer, tutorial: TutorialFeatureDiContainer) {

self.account = account
self.appLanguage = appLanguage
Expand All @@ -48,6 +49,7 @@ class AppFeatureDiContainer {
self.lessons = lessons
self.lessonProgress = lessonProgress
self.onboarding = onboarding
self.persistFavoritedToolLanguageSettings = persistFavoritedToolLanguageSettings
self.shareables = shareables
self.shareGodTools = shareGodTools
self.spotlightTools = spotlightTools
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// PersistUserToolLanguageSettingsDataLayerDependencies.swift
// godtools
//
// Created by Levi Eggert on 11/7/24.
// Copyright © 2024 Cru. All rights reserved.
//

import Foundation

class PersistUserToolLanguageSettingsDataLayerDependencies {

private let coreDataLayer: AppDataLayerDependencies

init(coreDataLayer: AppDataLayerDependencies) {

self.coreDataLayer = coreDataLayer
}

// MARK: - Data Layer Classes

func getUserToolSettingsRepository() -> UserToolSettingsRepository {
return UserToolSettingsRepository(
cache: RealmUserToolSettingsCache(realmDatabase: coreDataLayer.getSharedRealmDatabase())
)
}

// MARK: - Domain Interface

func getPersistUserToolLanguageSettingsRepositoryInterface() -> PersistUserToolLanguageSettingsRepositoryInterface {
return PersistUserToolLanguageSettingsRepository(
userToolSettingsRepository: getUserToolSettingsRepository()
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// PersistUserToolLanguageSettingsDiContainer.swift
// godtools
//
// Created by Levi Eggert on 11/7/24.
// Copyright © 2024 Cru. All rights reserved.
//

import Foundation

class PersistUserToolLanguageSettingsDiContainer {

let dataLayer: PersistUserToolLanguageSettingsDataLayerDependencies
let domainLayer: PersistUserToolLanguageSettingsDomainLayerDependencies

init(coreDataLayer: AppDataLayerDependencies) {

dataLayer = PersistUserToolLanguageSettingsDataLayerDependencies(coreDataLayer: coreDataLayer)
domainLayer = PersistUserToolLanguageSettingsDomainLayerDependencies(dataLayer: dataLayer)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// PersistUserToolLanguageSettingsDomainLayerDependencies.swift
// godtools
//
// Created by Levi Eggert on 11/7/24.
// Copyright © 2024 Cru. All rights reserved.
//

import Foundation

class PersistUserToolLanguageSettingsDomainLayerDependencies {

private let dataLayer: PersistUserToolLanguageSettingsDataLayerDependencies

init(dataLayer: PersistUserToolLanguageSettingsDataLayerDependencies) {

self.dataLayer = dataLayer
}

func getPersistUserToolLanguageSettingsUseCase() -> PersistUserToolLanguageSettingsUseCase {
return PersistUserToolLanguageSettingsUseCase(
persistUserToolLanguageSettingsRepositoryInterface: dataLayer.getPersistUserToolLanguageSettingsRepositoryInterface()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,8 @@ class ToolSettingsDataLayerDependencies {

// MARK: - Data Layer Classes

func getUserToolSettingsRepository() -> UserToolSettingsRepository {
return UserToolSettingsRepository(cache: getRealmUserToolSettingsCache())
}

func getRealmUserToolSettingsCache() -> RealmUserToolSettingsCache {
return RealmUserToolSettingsCache(realmDatabase: coreDataLayer.getSharedRealmDatabase())
}

// MARK: - Domain Interface

func getPersistUserToolLanguageSettingsRepositoryInterface() -> PersistUserToolLanguageSettingsRepositoryInterface {
return PersistUserToolLanguageSettingsRepository(
userToolSettingsRepository: getUserToolSettingsRepository()
)
}

func getShareToolInterfaceStringsRepositoryInterface() -> GetShareToolInterfaceStringsRepositoryInterface {
return GetShareToolInterfaceStringsRepository(
resourcesRepository: coreDataLayer.getResourcesRepository(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ class ToolSettingsDomainLayerDependencies {
self.dataLayer = dataLayer
}

func getPersistUserToolLanguageSettingsUseCase() -> PersistUserToolLanguageSettingsUseCase {
return PersistUserToolLanguageSettingsUseCase(
persistUserToolLanguageSettingsRepositoryInterface: dataLayer.getPersistUserToolLanguageSettingsRepositoryInterface()
)
}

func getViewShareToolUseCase() -> ViewShareToolUseCase {
return ViewShareToolUseCase(
getInterfaceStringsRepository: dataLayer.getShareToolInterfaceStringsRepositoryInterface()
Expand Down
2 changes: 1 addition & 1 deletion godtools/App/Flows/App/AppFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ extension AppFlow {

private func navigateToToolWithUserToolLanguageSettingsApplied(toolDataModelId: String, trainingTipsEnabled: Bool) {

let userToolSettingsRepository: UserToolSettingsRepository = appDiContainer.feature.toolSettings.dataLayer.getUserToolSettingsRepository()
let userToolSettingsRepository: UserToolSettingsRepository = appDiContainer.feature.persistFavoritedToolLanguageSettings.dataLayer.getUserToolSettingsRepository()

if let userToolSettings = userToolSettingsRepository.getUserToolSettings(toolId: toolDataModelId) {

Expand Down
2 changes: 1 addition & 1 deletion godtools/App/Flows/Tract/TractFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ extension TractFlow {
trainingTipsEnabled: trainingTipsEnabled,
incrementUserCounterUseCase: appDiContainer.domainLayer.getIncrementUserCounterUseCase(),
selectedLanguageIndex: selectedLanguageIndex,
persistUserToolLanguageSettingsUseCase: appDiContainer.feature.toolSettings.domainLayer.getPersistUserToolLanguageSettingsUseCase(),
persistUserToolLanguageSettingsUseCase: appDiContainer.feature.persistFavoritedToolLanguageSettings.domainLayer.getPersistUserToolLanguageSettingsUseCase(),
shouldPersistToolSettings: shouldPersistToolSettings
)

Expand Down
Loading