Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 52f9575

Browse files
committed
fix(auth): fix loading when non authenticated
fix(FAB): fix icon loading fix(webview): fix loading indicator
1 parent 143cfb0 commit 52f9575

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

WeLoop/Classes/Extensions/UIImage+base64.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension UIImage {
1717
}
1818

1919
static func weLoopIcon() -> UIImage? {
20-
let bundle = Bundle(for: WeLoop.self)
20+
let bundle = Bundle.weLoop
2121
return UIImage(named: "WeLoopIcon", in: bundle, compatibleWith: nil)
2222
}
2323
}

WeLoop/Classes/WeLoopButton.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class WeLoopButton: UIButton {
8787
func configureButton(settings: Settings) {
8888
guard let urlString = settings.iconUrl, let url = URL(string: urlString) else {
8989
color = settings.primaryColor
90-
setImage(UIImage.weLoopIcon(), for: .normal)
90+
let icon = UIImage.weLoopIcon()
91+
setImage(icon, for: .normal)
9192
return
9293
}
9394

WeLoop/Classes/WeLoopError.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,19 @@ import Foundation
99

1010
@objc public enum WeLoopError: Int, Error {
1111
case missingAPIKey
12-
case missingUserIdentification
1312
case configurationDataMissing
14-
case notificationDataMissing
1513
case windowMissing
16-
case authenticationInProgress
1714
}
1815

1916
extension WeLoopError: CustomStringConvertible {
2017
public var description: String {
2118
switch self {
2219
case .missingAPIKey:
2320
return "API key is missing. Make sure to call the `initialize` function first"
24-
case .missingUserIdentification:
25-
return "User info is missing. Make sure to call the `identifyUser` function first"
26-
case .notificationDataMissing:
27-
return "We could not parse the response of the notification refresh call because the data is missing"
2821
case .configurationDataMissing:
2922
return "We could not parse the response of the configuration call because the data is missing"
3023
case .windowMissing:
3124
return "Failed to acquire a ref to the window"
32-
case .authenticationInProgress:
33-
return "Authentication is still in progress"
3425
}
3526
}
3627
}

WeLoop/Classes/WeLoopViewController.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum WeLoopWebAction: String, CaseIterable {
1414
case getCapture = "WeloopGetCapture"
1515
case getCurrentUser = "GetCurrentUser"
1616
case setNotificationCount = "SetNotificationCount"
17+
case isLoaded = "IsLoaded"
1718
}
1819

1920
class WeLoopViewController: UIViewController {
@@ -113,8 +114,12 @@ class WeLoopViewController: UIViewController {
113114
}
114115

115116
func sendCurrentUser() {
116-
guard let uuid = WeLoop.shared.apiKey, let token = WeLoop.shared.authenticationToken else { return }
117-
webView?.evaluateJavaScript("GetCurrentUser({ appGuid: '\(uuid)', token: '\(token)'})")
117+
guard let uuid = WeLoop.shared.apiKey else { return }
118+
if let token = WeLoop.shared.authenticationToken {
119+
webView?.evaluateJavaScript("GetCurrentUser({ appGuid: '\(uuid)', token: '\(token)'})")
120+
} else {
121+
webView?.evaluateJavaScript("GetCurrentUser({ appGuid: '\(uuid)'})")
122+
}
118123
}
119124
}
120125

@@ -131,6 +136,9 @@ extension WeLoopViewController: WKScriptMessageHandler {
131136
case .setNotificationCount:
132137
guard let body = message.body as? [String: Any], let count = body["number"] as? Int else { return }
133138
WeLoop.shared.setNotificationBadge(count: count)
139+
case .isLoaded:
140+
indicator.stopAnimating()
141+
webView.backgroundColor = .clear
134142
}
135143
}
136144
}
@@ -152,11 +160,4 @@ extension WeLoopViewController: WKNavigationDelegate {
152160
}
153161
}
154162
}
155-
156-
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
157-
indicator.stopAnimating()
158-
//TODO: commented out for now, but at this point the load is finished (files have been loaded) and the spa should render
159-
// a loader. This is not done immediately so there is a little lag, but I can't do anything more on the native side.
160-
//webView.backgroundColor = .clear
161-
}
162163
}

0 commit comments

Comments
 (0)