Skip to content

Commit

Permalink
Merge pull request #2286 from CruGlobal/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
levieggertcru authored Oct 3, 2024
2 parents 1be0337 + 76231a3 commit fd6b918
Show file tree
Hide file tree
Showing 33 changed files with 116 additions and 155 deletions.
1 change: 1 addition & 0 deletions .github/workflows/download_onesky_translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ jobs:
branch: 'latest-onesky-translations'
token: ${{ secrets.CREATE_PULL_REQUEST_ACCESS_TOKEN }}
title: 'Latest OneSky Translations'
add-paths: godtools/*
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.975.0)
aws-sdk-core (3.205.0)
aws-partitions (1.981.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.162.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.9.1)
aws-sigv4 (1.10.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
Expand Down Expand Up @@ -97,7 +97,7 @@ GEM
ethon (0.16.0)
ffi (>= 1.15.0)
excon (0.111.0)
faraday (1.10.3)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -123,10 +123,10 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.222.0)
fastlane (2.223.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -220,7 +220,7 @@ GEM
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.7.2)
jwt (2.9.0)
jwt (2.9.1)
base64
logger (1.6.1)
mime-types (3.5.2)
Expand Down Expand Up @@ -254,7 +254,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.3.7)
rexml (3.3.8)
rouge (2.0.7)
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
Expand Down
24 changes: 0 additions & 24 deletions godtools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1605,8 +1605,6 @@
D4E7EE052C780C8800F75DA6 /* LinkShareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EEB67C2C75371E006F0D39 /* LinkShareable.swift */; };
D4EAF2F92C0F95D900AEC36C /* UserToolSettingsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EAF2F82C0F95D900AEC36C /* UserToolSettingsRepository.swift */; };
D4EEB67B2C7518AF006F0D39 /* ConfirmAppLanguageHighlightStringDomainModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EEB67A2C7518AF006F0D39 /* ConfirmAppLanguageHighlightStringDomainModel.swift */; };
D4EFC9632B49B28200B0D34A /* LanguageDownloadErrorAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EFC9622B49B28200B0D34A /* LanguageDownloadErrorAlertView.swift */; };
D4EFC9652B49B29D00B0D34A /* LanguageDownloadErrorAlertViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EFC9642B49B29D00B0D34A /* LanguageDownloadErrorAlertViewModel.swift */; };
D4F0457B2BBB464D00B115C9 /* RealmUserToolFiltersCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F0457A2BBB464D00B115C9 /* RealmUserToolFiltersCache.swift */; };
D4F0457D2BBB469A00B115C9 /* RealmUserToolCategoryFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F0457C2BBB469A00B115C9 /* RealmUserToolCategoryFilter.swift */; };
D4F0457F2BBB479D00B115C9 /* RealmUserToolLanguageFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F0457E2BBB479D00B115C9 /* RealmUserToolLanguageFilter.swift */; };
Expand Down Expand Up @@ -3366,8 +3364,6 @@
D4EAF2F82C0F95D900AEC36C /* UserToolSettingsRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserToolSettingsRepository.swift; sourceTree = "<group>"; };
D4EEB67A2C7518AF006F0D39 /* ConfirmAppLanguageHighlightStringDomainModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmAppLanguageHighlightStringDomainModel.swift; sourceTree = "<group>"; };
D4EEB67C2C75371E006F0D39 /* LinkShareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkShareable.swift; sourceTree = "<group>"; };
D4EFC9622B49B28200B0D34A /* LanguageDownloadErrorAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageDownloadErrorAlertView.swift; sourceTree = "<group>"; };
D4EFC9642B49B29D00B0D34A /* LanguageDownloadErrorAlertViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageDownloadErrorAlertViewModel.swift; sourceTree = "<group>"; };
D4F0457A2BBB464D00B115C9 /* RealmUserToolFiltersCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmUserToolFiltersCache.swift; sourceTree = "<group>"; };
D4F0457C2BBB469A00B115C9 /* RealmUserToolCategoryFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmUserToolCategoryFilter.swift; sourceTree = "<group>"; };
D4F0457E2BBB479D00B115C9 /* RealmUserToolLanguageFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmUserToolLanguageFilter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8174,7 +8170,6 @@
45AC9DE72B28A9CD00DEEBFE /* Subviews */ = {
isa = PBXGroup;
children = (
D4EFC9612B49B26200B0D34A /* LanguageDownloadErrorAlertView */,
45AC9DE82B28A9CD00DEEBFE /* DownloadableLanguageItemView.swift */,
45AC9DE92B28A9CD00DEEBFE /* LanguageDownloadIcon.swift */,
);
Expand Down Expand Up @@ -11251,13 +11246,6 @@
path = Subviews;
sourceTree = "<group>";
};
D40D77BD2AB23183008D3642 /* Models */ = {
isa = PBXGroup;
children = (
);
path = Models;
sourceTree = "<group>";
};
D4159D512C2CE0240088A203 /* PersistUserToolLanguageSettings */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -11478,7 +11466,6 @@
D40D77B42AA900FB008D3642 /* ToolStringKeys.swift */,
45920D4E2A8D3D1800E336A8 /* ToolsView.swift */,
45920D4D2A8D3D1800E336A8 /* ToolsViewModel.swift */,
D40D77BD2AB23183008D3642 /* Models */,
45DD84C42A8BD53E0066A020 /* Subviews */,
);
path = Tools;
Expand Down Expand Up @@ -11825,15 +11812,6 @@
path = "SwiftUI Modifiers";
sourceTree = "<group>";
};
D4EFC9612B49B26200B0D34A /* LanguageDownloadErrorAlertView */ = {
isa = PBXGroup;
children = (
D4EFC9622B49B28200B0D34A /* LanguageDownloadErrorAlertView.swift */,
D4EFC9642B49B29D00B0D34A /* LanguageDownloadErrorAlertViewModel.swift */,
);
path = LanguageDownloadErrorAlertView;
sourceTree = "<group>";
};
D4F1DE8E2967539200A2F674 /* IncrementUserCounterUseCase */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -12473,7 +12451,6 @@
D455F3ED2977302D009D5F93 /* GetUserActivityUseCase.swift in Sources */,
4598BD1B2BF7DF6800196463 /* AccountDomainLayerDependencies.swift in Sources */,
D4B060022912C335005852D0 /* MobileContentAuthTokenCache.swift in Sources */,
D4EFC9632B49B28200B0D34A /* LanguageDownloadErrorAlertView.swift in Sources */,
450397332B360F1B00938EE9 /* IdentifiableRealmObject.swift in Sources */,
4534F93E2AE9B11600A7A071 /* LessonEvaluationRepository.swift in Sources */,
450D7B0228E32965006C3FDF /* TrackDownloadedTranslationsCache.swift in Sources */,
Expand Down Expand Up @@ -13278,7 +13255,6 @@
458CFE9B29D4E0B9007B423C /* ArticleCategoryCellViewModel.swift in Sources */,
D47DF0462B2A3D5D0079219B /* DownloadedLanguageDataModel.swift in Sources */,
45D814D32B81056B00AD00C5 /* SpotlightToolsDiContainer.swift in Sources */,
D4EFC9652B49B29D00B0D34A /* LanguageDownloadErrorAlertViewModel.swift in Sources */,
45C1527F2A44888100F2A1E8 /* LessonEvaluationView.swift in Sources */,
45AF47ED2B35E03500361EA7 /* GetToolSettingsToolHasTipsRepositoryInterface.swift in Sources */,
D42FEBDA287604570002FAD9 /* OptInOnboardingBannerEnabledRepository.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,37 @@ class DownloadToolLanguageRepository: DownloadToolLanguageRepositoryInterface {
self.toolLanguageDownloader = toolLanguageDownloader
}

func downloadToolTranslations(for languageId: String, languageCode: BCP47LanguageIdentifier) -> AnyPublisher<Double, Never> {
func downloadToolTranslations(for languageId: String, languageCode: BCP47LanguageIdentifier) -> AnyPublisher<Double, Error> {

downloadedLanguagesRepository.storeDownloadedLanguage(languageId: languageId, downloadComplete: false)

return toolLanguageDownloader
.downloadToolLanguagePublisher(languageId: languageId)
.map {
.catch { (downloadError: Error) -> AnyPublisher<ToolDownloaderDataModel, Error> in

let progress = $0.progress
return self.downloadedLanguagesRepository.deleteDownloadedLanguagePublisher(languageId: languageId)
.catch { (deleteError: Error) -> AnyPublisher<Void, Error> in

assertionFailure("Failed to delete object in RealmDatabase. \(deleteError.localizedDescription)")

return Fail(error: downloadError)
.eraseToAnyPublisher()
}
.flatMap({ (void: Void) -> AnyPublisher<ToolDownloaderDataModel, Error> in
return Fail(error: downloadError)
.eraseToAnyPublisher()
})
.eraseToAnyPublisher()
}
.map { (dataModel: ToolDownloaderDataModel) in

let progress = dataModel.progress

if progress >= 1 {
self.downloadedLanguagesRepository.storeDownloadedLanguage(languageId: languageId, downloadComplete: true)
}

return $0.progress
return dataModel.progress
}
.eraseToAnyPublisher()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ class ToolLanguageDownloader {
self.downloadedLanguagesRepository = downloadedLanguagesRepository
}

func downloadToolLanguagePublisher(languageId: String) -> AnyPublisher<ToolDownloaderDataModel, Never> {
func downloadToolLanguagePublisher(languageId: String) -> AnyPublisher<ToolDownloaderDataModel, Error> {

guard let languageModel = languagesRepository.getLanguage(id: languageId) else {

let emptyDownload = ToolDownloaderDataModel(attachments: [], progress: 1, translations: [])
let error: Error = NSError.errorWithDomain(domain: "ToolLanguageDownloader", code: -1, description: "Internal Error in ToolLanguageDownloader. Failed to fetch language with language id: \(languageId)")

return Just(emptyDownload)
return Fail(error: error)
.eraseToAnyPublisher()
}

let includeToolTypes: [ResourceType] = ResourceType.toolTypes + [.lesson]

let tools: [ResourceModel] = resourcesRepository.getCachedResourcesByFilter(filter: ResourcesFilter(category: nil, languageModelCode: languageModel.code, resourceTypes: includeToolTypes))
let tools: [ResourceModel] = resourcesRepository.getCachedResourcesByFilter(
filter: ResourcesFilter(category: nil, languageModelCode: languageModel.code, resourceTypes: includeToolTypes)
)

let downloadTools: [DownloadToolDataModel] = tools.map({
DownloadToolDataModel(toolId: $0.id, languages: [languageModel.code])
Expand All @@ -46,12 +48,12 @@ class ToolLanguageDownloader {
.eraseToAnyPublisher()
}

func syncDownloadedLanguagesPublisher() -> AnyPublisher<Void, Never> {
func syncDownloadedLanguagesPublisher() -> AnyPublisher<Void, Error> {

return downloadedLanguagesRepository.getDownloadedLanguagesPublisher(completedDownloadsOnly: false)
.flatMap({ (downloadedLanguages: [DownloadedLanguageDataModel]) -> AnyPublisher<Void, Never> in
.flatMap({ (downloadedLanguages: [DownloadedLanguageDataModel]) -> AnyPublisher<Void, Error> in

let downloadToolLanguageRequests = downloadedLanguages.map({
let downloadToolLanguageRequests: [AnyPublisher<ToolDownloaderDataModel, Error>] = downloadedLanguages.map({
self.downloadToolLanguagePublisher(languageId: $0.languageId)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import Combine

protocol DownloadToolLanguageRepositoryInterface {

func downloadToolTranslations(for languageId: String, languageCode: BCP47LanguageIdentifier) -> AnyPublisher<Double, Never>
func downloadToolTranslations(for languageId: String, languageCode: BCP47LanguageIdentifier) -> AnyPublisher<Double, Error>
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DownloadToolLanguageUseCase {
self.downloadToolLanguageRepository = downloadToolLanguageRepository
}

func downloadToolLanguage(languageId: String, languageCode: BCP47LanguageIdentifier) -> AnyPublisher<Double, Never> {
func downloadToolLanguage(languageId: String, languageCode: BCP47LanguageIdentifier) -> AnyPublisher<Double, Error> {

return downloadToolLanguageRepository.downloadToolTranslations(for: languageId, languageCode: languageCode)
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class FavoritedToolsLatestToolDownloader: FavoritedToolsLatestToolDownloaderInte
.map { _ in
return Void()
}
.catch { _ in
return Just(Void())
}
.eraseToAnyPublisher()
})
.eraseToAnyPublisher()
Expand Down
9 changes: 6 additions & 3 deletions godtools/App/Flows/App/AppFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,19 @@ extension AppFlow {

resourcesRepository
.syncLanguagesAndResourcesPlusLatestTranslationsAndLatestAttachmentsIgnoringErrorPublisher()
.flatMap({ _ -> AnyPublisher<Void, Never> in
.setFailureType(to: Error.self)
.flatMap({ (result: RealmResourcesCacheSyncResult) -> AnyPublisher<Void, Error> in

return self.toolLanguageDownloader
.syncDownloadedLanguagesPublisher()
.eraseToAnyPublisher()
})
.receive(on: DispatchQueue.main)
.sink { _ in
.sink(receiveCompletion: { _ in

}
}, receiveValue: { _ in

})
.store(in: &cancellables)

_ = followUpsService.postFailedFollowUpsIfNeeded()
Expand Down
21 changes: 10 additions & 11 deletions godtools/App/Flows/LanguageSettings/LanguageSettingsFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class LanguageSettingsFlow: Flow, ChooseAppLanguageNavigationFlow {

private weak var flowDelegate: FlowDelegate?

@Published private var appLanguage: AppLanguageDomainModel = ""

let appDiContainer: AppDiContainer
let navigationController: AppNavigationController

Expand All @@ -37,6 +39,12 @@ class LanguageSettingsFlow: Flow, ChooseAppLanguageNavigationFlow {

sharedNavigationController.pushViewController(initialView, animated: true)
}

appDiContainer.feature.appLanguage.domainLayer
.getCurrentAppLanguageUseCase()
.getLanguagePublisher()
.receive(on: DispatchQueue.main)
.assign(to: &$appLanguage)
}

deinit {
Expand All @@ -53,7 +61,7 @@ class LanguageSettingsFlow: Flow, ChooseAppLanguageNavigationFlow {
case .chooseAppLanguageTappedFromLanguageSettings:
navigateToChooseAppLanguageFlow()

case .chooseAppLanguageFlowCompleted(let state):
case .chooseAppLanguageFlowCompleted( _):
navigateBackFromChooseAppLanguageFlow()

case .editDownloadedLanguagesTappedFromLanguageSettings:
Expand All @@ -63,8 +71,7 @@ class LanguageSettingsFlow: Flow, ChooseAppLanguageNavigationFlow {
navigationController.popViewController(animated: true)

case .showLanguageDownloadErrorAlert(let error):
let alertView = getLanguageDownloadErrorAlertView(error: error)
navigationController.present(alertView, animated: true)
presentError(appLanguage: appLanguage, error: error)

default:
break
Expand Down Expand Up @@ -135,12 +142,4 @@ extension LanguageSettingsFlow {

return hostingView
}

func getLanguageDownloadErrorAlertView(error: Error) -> UIViewController {

let viewModel = LanguageDownloadErrorAlertViewModel(error: error)
let view = LanguageDownloadErrorAlertView(viewModel: viewModel)

return view.controller
}
}
Loading

0 comments on commit fd6b918

Please sign in to comment.