Skip to content

Commit

Permalink
Merge pull request #2345 from CruGlobal/GT-remove-check-for-is-tests-…
Browse files Browse the repository at this point in the history
…target

GT-remove-check-for-is-tests-target
  • Loading branch information
levieggertcru authored Nov 11, 2024
2 parents 6e4d972 + c27a116 commit ef4f726
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ class AppDataLayerDependencies {
func getTranslationsRepository() -> TranslationsRepository {
return TranslationsRepository(
infoPlist: getInfoPlist(),
appBuild: getAppBuild(),
api: MobileContentTranslationsApi(config: getAppConfig(), ignoreCacheSession: sharedIgnoreCacheSession),
cache: RealmTranslationsCache(realmDatabase: sharedRealmDatabase),
resourcesFileCache: getResourcesFileCache(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ParseTranslationManifestForRenderer: TranslationManifestParser {
ParserConfig.companion.FEATURE_MULTISELECT
]

init(infoPlist: InfoPlist, resourcesFileCache: ResourcesSHA256FileCache, appBuild: AppBuild) {
init(infoPlist: InfoPlist, resourcesFileCache: ResourcesSHA256FileCache) {

let appVersion: String? = infoPlist.appVersion

Expand All @@ -35,8 +35,7 @@ class ParseTranslationManifestForRenderer: TranslationManifestParser {

super.init(
parserConfig: parserConfig,
resourcesFileCache: resourcesFileCache,
appBuild: appBuild
resourcesFileCache: resourcesFileCache
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ class TranslationManifestParser {
private let parser: ManifestParser
private let parserConfig: ParserConfig
private let resourcesFileCache: ResourcesSHA256FileCache
private let appBuild: AppBuild

static func getManifestParser(type: TranslationManifestParserType, infoPlist: InfoPlist, resourcesFileCache: ResourcesSHA256FileCache, appBuild: AppBuild) -> TranslationManifestParser {
static func getManifestParser(type: TranslationManifestParserType, infoPlist: InfoPlist, resourcesFileCache: ResourcesSHA256FileCache) -> TranslationManifestParser {

switch type {

case .manifestOnly:
let parserConfig = ParserConfig().withParseRelated(enabled: false)
return TranslationManifestParser(parserConfig: parserConfig, resourcesFileCache: resourcesFileCache, appBuild: appBuild)
return TranslationManifestParser(parserConfig: parserConfig, resourcesFileCache: resourcesFileCache)

case .renderer:
return ParseTranslationManifestForRenderer(infoPlist: infoPlist, resourcesFileCache: resourcesFileCache, appBuild: appBuild)
return ParseTranslationManifestForRenderer(infoPlist: infoPlist, resourcesFileCache: resourcesFileCache)
}
}

init(parserConfig: ParserConfig, resourcesFileCache: ResourcesSHA256FileCache, appBuild: AppBuild) {
init(parserConfig: ParserConfig, resourcesFileCache: ResourcesSHA256FileCache) {

self.parser = ManifestParser(
parserFactory: TranslationManifestParserFactory(resourcesFileCache: resourcesFileCache),
Expand All @@ -39,7 +38,6 @@ class TranslationManifestParser {

self.parserConfig = parserConfig
self.resourcesFileCache = resourcesFileCache
self.appBuild = appBuild
}

func parsePublisher(manifestName: String) -> AnyPublisher<Manifest, Error> {
Expand All @@ -63,13 +61,6 @@ class TranslationManifestParser {

private func parseAsync(manifestName: String, completion: @escaping ((_ result: Result<Manifest, Error>) -> Void)) {

// TODO: Currently this is here to fix a random crash in godtoolsTests (See GT-2047). Is this the best way to prevent this code from running in godtoolsTests? Investigate this more. ~Levi

guard !appBuild.isTestsTarget else {
completion(.failure(NSError.errorWithDescription(description: "Running tests will not parse manifest.")))
return
}

let location: FileCacheLocation = FileCacheLocation(relativeUrlString: manifestName)

switch resourcesFileCache.getFileExists(location: location) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import RequestOperation
class TranslationsRepository {

private let infoPlist: InfoPlist
private let appBuild: AppBuild
private let api: MobileContentTranslationsApi
private let cache: RealmTranslationsCache
private let resourcesFileCache: ResourcesSHA256FileCache
private let trackDownloadedTranslationsRepository: TrackDownloadedTranslationsRepository

init(infoPlist: InfoPlist, appBuild: AppBuild, api: MobileContentTranslationsApi, cache: RealmTranslationsCache, resourcesFileCache: ResourcesSHA256FileCache, trackDownloadedTranslationsRepository: TrackDownloadedTranslationsRepository) {
init(infoPlist: InfoPlist, api: MobileContentTranslationsApi, cache: RealmTranslationsCache, resourcesFileCache: ResourcesSHA256FileCache, trackDownloadedTranslationsRepository: TrackDownloadedTranslationsRepository) {

self.infoPlist = infoPlist
self.appBuild = appBuild
self.api = api
self.cache = cache
self.resourcesFileCache = resourcesFileCache
Expand Down Expand Up @@ -69,7 +67,7 @@ extension TranslationsRepository {

func getTranslationManifestFromCache(translation: TranslationModel, manifestParserType: TranslationManifestParserType, includeRelatedFiles: Bool) -> AnyPublisher<TranslationManifestFileDataModel, Error> {

let manifestParser: TranslationManifestParser = TranslationManifestParser.getManifestParser(type: manifestParserType, infoPlist: infoPlist, resourcesFileCache: resourcesFileCache, appBuild: appBuild)
let manifestParser: TranslationManifestParser = TranslationManifestParser.getManifestParser(type: manifestParserType, infoPlist: infoPlist, resourcesFileCache: resourcesFileCache)

return manifestParser.parsePublisher(manifestName: translation.manifestName)
.flatMap({ manifest -> AnyPublisher<TranslationManifestFileDataModel, Error> in
Expand Down Expand Up @@ -199,7 +197,7 @@ extension TranslationsRepository {
return getTranslationFileFromCacheElseRemote(translation: translation, fileName: translation.manifestName)
.flatMap({ fileCacheLocation -> AnyPublisher<Manifest, Error> in

let manifestParser: TranslationManifestParser = TranslationManifestParser.getManifestParser(type: manifestParserType, infoPlist: self.infoPlist, resourcesFileCache: self.resourcesFileCache, appBuild: self.appBuild)
let manifestParser: TranslationManifestParser = TranslationManifestParser.getManifestParser(type: manifestParserType, infoPlist: self.infoPlist, resourcesFileCache: self.resourcesFileCache)

return manifestParser.parsePublisher(manifestName: translation.manifestName)
.eraseToAnyPublisher()
Expand Down Expand Up @@ -324,7 +322,7 @@ extension TranslationsRepository {
return getTranslationFileFromCacheElseRemote(translation: translation, fileName: translation.manifestName)
.flatMap({ (fileCacheLocation: FileCacheLocation) -> AnyPublisher<Manifest, Error> in

let manifestParser: TranslationManifestParser = TranslationManifestParser.getManifestParser(type: .manifestOnly, infoPlist: self.infoPlist, resourcesFileCache: self.resourcesFileCache, appBuild: self.appBuild)
let manifestParser: TranslationManifestParser = TranslationManifestParser.getManifestParser(type: .manifestOnly, infoPlist: self.infoPlist, resourcesFileCache: self.resourcesFileCache)

return manifestParser.parsePublisher(manifestName: translation.manifestName)
.eraseToAnyPublisher()
Expand Down

0 comments on commit ef4f726

Please sign in to comment.