diff --git a/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift b/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift index ccfc207741e4aa..9a2aefbfdf81b8 100644 --- a/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift +++ b/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift @@ -5,34 +5,21 @@ public struct MediaInfo: Encodable { public let title: String? public let caption: String? public let alt: String? - public let metadata: Encodable + public let metadata: [String: Any] private enum CodingKeys: String, CodingKey { - case id, url, type, title, caption, alt, metadata + case id, url, type, title, caption, alt } - public init(id: Int32?, url: String?, type: String?, caption: String? = nil, title: String? = nil, alt: String? = nil, metadata: Encodable? = nil) { + public init(id: Int32?, url: String?, type: String?, caption: String? = nil, title: String? = nil, alt: String? = nil, metadata: [String: Any] = [:]) { self.id = id self.url = url self.type = type self.caption = caption self.title = title self.alt = alt - self.metadata = metadata ?? [:] as [String: String] + self.metadata = metadata } - - public func encode (to encoder: Encoder) throws - { - var container = encoder.container (keyedBy: CodingKeys.self) - try container.encode (id, forKey: .id) - try container.encode (url, forKey: .url) - try container.encode (type, forKey: .type) - try container.encode (title, forKey: .title) - try container.encode (caption, forKey: .caption) - try container.encode (alt, forKey: .alt) - var metadataContainer = container.nestedUnkeyedContainer(forKey: .metadata) - try metadata.encode(to: metadataContainer.superEncoder()) - } } /// Definition of capabilities to enable in the Block Editor diff --git a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift index 162bdc3fec7d7c..e751bbe4d838c3 100644 --- a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -468,12 +468,13 @@ extension MediaInfo { func encodeForJS() -> [String: Any] { guard let data = try? JSONEncoder().encode(self), - let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else + var jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { assertionFailure("Encoding of MediaInfo failed") return [String: Any]() } + jsonObject["metadata"] = self.metadata return jsonObject } }