Take2: allow NON_US share server and custom share server#509
Take2: allow NON_US share server and custom share server#509ps2 merged 2 commits intoLoopKit:devfrom dabear:dev
Conversation
| options: [ | ||
| (title: NSLocalizedString("US", comment: "U.S. share server option title"), | ||
| value: DexcomShareURL.absoluteString) | ||
| value: DexcomShareURL.absoluteString), |
There was a problem hiding this comment.
DexcomShareURL should be replaced everywhere with the new string constants from Mark’s lib
| if let username = username, let password = password, url != nil { | ||
| isAuthorized = true | ||
| client = ShareClient(username: username, password: password) | ||
| client = ShareClient(username: username, password: password, shareServer: url!.absoluteString) |
There was a problem hiding this comment.
Should avoid use of ! with let url = url, in the if statement above
There was a problem hiding this comment.
Yeah, agreed. Can you explain why the url != nil was added in the first place (rather than let url = url)..?
There was a problem hiding this comment.
url wasn't used at that point; it would not compile with a let (would be an unused variable), so it was just a hint.
| } | ||
|
|
||
| let client = ShareClient(username: username, password: password) | ||
| let client = ShareClient(username: username, password: password, shareServer: url!.absoluteString) |
| ) | ||
| ] | ||
|
|
||
| if customServer.characters.count > 0 { |
There was a problem hiding this comment.
Using nullable/optional var here would be better than counting chars.
There was a problem hiding this comment.
I started doing that, but realized having an optional set to an initial state of nil would be more difficult to grasp for novice users not accustomed to editing code, instead of editing just the contents between two quotation marks.
I guess i could use an optional with a more extensive description
There was a problem hiding this comment.
Or maybe don't even set a string at all in the no-custom-server case; just have a block of code that is completely commented out.
|
|
||
| init(username: String?, password: String?, url: URL?) { | ||
| // change the contents of the variable below to point to your custom share server | ||
| let customServer = "" |
There was a problem hiding this comment.
Feel free to expand upon how to do this; like linking to your repo/blog. Also, do you want to describe how to change the name as shown in the UI from "Custom"?
|
The requested changes should now been added. Please verify :) |
This adds an option to select US and NON_US share servers in the GUI. Also, if the customServer variable is filled out, a third option for selecting "Custom" share server will appear in the GUI