-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/translation api by name #9
Feature/translation api by name #9
Conversation
…/MikePT28/halo-ios into feature/translation-api-by-name * 'feature/enable_change_credential' of https://github.com/MikePT28/halo-ios: [CoreManager]: update how to setup app credentials
…/MikePT28/halo-ios into feature/translation-api-by-name * 'feature/enable_change_credential' of https://github.com/MikePT28/halo-ios: [Coremanager]: delete unused private functions
…/MikePT28/halo-ios into feature/translation-api-by-name * 'feature/enable_change_credential' of https://github.com/MikePT28/halo-ios: [Core]: update core to allow editing environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the comments left on the files
@@ -18,7 +18,7 @@ extension ContentManager { | |||
|
|||
public func sync(query: SyncQuery, completionHandler handler: @escaping (String, HaloError?) -> Void) -> Void { | |||
|
|||
let path = getPath(file: "synctimestamp-\(query.moduleId)") | |||
let path = getPath(file: "synctimestamp-\(query.moduleId!)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's no moduleId the string would read: "synctimestamp-nil" or the worst case is a thread access error.
Please wrap it into a guard so that if there's no moduleId return a HaloError to the user
// Copyright © 2017 MOBGEN Technology. All rights reserved. | ||
// | ||
|
||
import Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move as a second extension on the ContentManager+Sync.swift file
@@ -21,14 +21,16 @@ open class SyncQuery: NSObject { | |||
|
|||
open fileprivate(set) var locale: Locale = Manager.content.defaultLocale | |||
open fileprivate(set) var moduleName: String? | |||
open fileprivate(set) var moduleId: String = "" | |||
open fileprivate(set) var moduleId: String? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change ? to ! and make sure it is never nil when used
if let id = moduleId { | ||
Manager.content.sync(query: syncQuery) { moduleId, error in | ||
self.processSyncResult(moduleId: id, error: error) | ||
self.completionHandlers.forEach { $0(error) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid duplicating this line, make an inline closure/block/lambda and call it here and on the other place where used
} | ||
|
||
if let username = data[usernameKey] as? String, let password = data[passwordKey] as? String { | ||
self.userCredentials = Credentials(username: username, password: password) | ||
if(self.appCredentials != nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to userCredentials
Sources/Managers/CoreManager.swift
Outdated
} | ||
|
||
if let tags = data[CoreConstants.enableSystemTags] as? Bool { | ||
self.enableSystemTags = tags | ||
} | ||
|
||
if let env = data[environmentKey] as? String { | ||
if(self.env != nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to if let
Sources/Managers/CoreManager.swift
Outdated
|
||
- parameter env: The env to set | ||
*/ | ||
public func setEndpoint(_ env: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this setter and change it's uses to direct setting of the var.
…/MikePT28/halo-ios into feature/translation-api-by-name * 'feature/enable_change_credential' of https://github.com/MikePT28/halo-ios: Update due to PR review comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All seems correct. Great job!
Get translations by module name