Browse Source

Added refresh token status in remote view and improved the help text.

Jonas Björkert 2 years ago
parent
commit
345422f90b

+ 1 - 1
LoopFollow/Remote/RemoteView.swift

@@ -44,7 +44,7 @@ struct RemoteView: View {
                     )
                 } else if !nsWriteAuth.value {
                     ErrorMessageView(
-                        message: "Please enter a valid token with appropriate permissions in the settings."
+                        message: "Please update your token to include the 'careportal' and 'readable' roles in order to do remote commands."
                     )
                 } else {
                     Form {

+ 8 - 0
LoopFollow/Remote/RemoteViewController.swift

@@ -33,6 +33,14 @@ class RemoteViewController: UIViewController {
         ])
 
         hostingController.didMove(toParent: self)
+
+        if(!ObservableUserDefaults.shared.nsWriteAuth.value) {
+            NightscoutUtils.verifyURLAndToken { error, jwtToken, nsWriteAuth in
+                DispatchQueue.main.async {
+                    ObservableUserDefaults.shared.nsWriteAuth.value = nsWriteAuth
+                }
+            }
+        }
     }
 
     private func cancelExistingTarget(completion: @escaping (Bool) -> Void) {