mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
EC Timeout if it doesn't respond after 30 seconds (#4237)
* basic implementation * using a decodable struct to interpret the widget message * small code refactor/improvement
This commit is contained in:
@@ -94,3 +94,23 @@ enum CallScreenJavaScriptMessageName: String, CaseIterable {
|
||||
allCases.map(\.postMessageScript).joined(separator: "\n")
|
||||
}
|
||||
}
|
||||
|
||||
struct DecodedWidgetMessage: Decodable {
|
||||
private static let decoder = JSONDecoder()
|
||||
private static let joinAction = "io.element.join"
|
||||
private static let fromWidget = "fromWidget"
|
||||
|
||||
let action: String?
|
||||
let api: String?
|
||||
|
||||
static func decode(message: String) throws -> DecodedWidgetMessage? {
|
||||
guard let data = message.data(using: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
return try decoder.decode(DecodedWidgetMessage.self, from: data)
|
||||
}
|
||||
|
||||
var hasJoined: Bool {
|
||||
action == Self.joinAction && api == Self.fromWidget
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user