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

Feature/translation api by name #9

Merged
merged 13 commits into from
Nov 30, 2017

Conversation

ficiverson
Copy link

Get translations by module name

@ficiverson ficiverson changed the base branch from master to develop November 30, 2017 08:56
Copy link
Collaborator

@MikePT28 MikePT28 left a 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!)")
Copy link
Collaborator

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
Copy link
Collaborator

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?
Copy link
Collaborator

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) }
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to userCredentials

}

if let tags = data[CoreConstants.enableSystemTags] as? Bool {
self.enableSystemTags = tags
}

if let env = data[environmentKey] as? String {
if(self.env != nil) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to if let


- parameter env: The env to set
*/
public func setEndpoint(_ env: String) {
Copy link
Collaborator

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.

Copy link
Collaborator

@MikePT28 MikePT28 left a 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!

@MikePT28 MikePT28 merged commit 53e53d5 into mobgen:develop Nov 30, 2017
@MikePT28 MikePT28 deleted the feature/translation-api-by-name branch November 30, 2017 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants