File tree Expand file tree Collapse file tree 5 files changed +35
-9
lines changed
Expand file tree Collapse file tree 5 files changed +35
-9
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,27 @@ import AnyCodable
99import Foundation
1010
1111public struct MatrixStateEvent : MatrixEvent {
12+ public init (
13+ eventID: String ? = nil ,
14+ stateKey: String = " " ,
15+ sender: MatrixFullUserIdentifier ? = nil ,
16+ date: Date ? = nil ,
17+ unsigned: AnyCodable ? = nil ,
18+ content: MatrixStateEventType
19+ ) {
20+ self . stateKey = stateKey
21+ self . eventID = eventID
22+ self . sender = sender
23+ self . date = date
24+ self . unsigned = unsigned
25+ self . content = content
26+ }
27+
1228 public static let type : String = " "
1329
1430 /// The content of the event.
1531 @MatrixCodableStateEventType
16- var content : MatrixStateEventType
32+ public var content : MatrixStateEventType
1733
1834 public var stateKey : String = " "
1935
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ public struct MatrixCodableEvents<Value: Collection>: Codable where Value.Elemen
149149 let wrappers = try container. decode ( [ EventWrapper < Value . Element > ] . self)
150150 wrappedValue = wrappers. compactMap ( \. wrappedEvent) as? Value
151151 } catch {
152- if #available( iOS 14 . 0 , * ) {
152+ if #available( iOS 14 . 0 , macOS 11 . 0 , * ) {
153153 MatrixClient . logger. warning ( " Failed to parse sync: \( error. localizedDescription) " )
154154 } else { }
155155 }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public extension CodingUserInfoKey {
2323}
2424
2525@propertyWrapper
26- public struct MatrixCodableStateEventType {
26+ public struct MatrixCodableStateEventType : Encodable {
2727 public var wrappedValue : MatrixStateEventType
2828
2929 public init ( wrappedValue: MatrixStateEventType ) {
@@ -62,8 +62,4 @@ public struct MatrixCodableStateEventType {
6262 }
6363 }
6464 }
65-
66- struct Container < T: MatrixStateEventType > : Codable {
67- var content : T
68- }
6965}
Original file line number Diff line number Diff line change @@ -31,6 +31,20 @@ public struct MatrixRoomCanonicalAliasEvent: MatrixStateEventType {
3131
3232/// This is the first event in a room and cannot be changed. It acts as the root of all other events.
3333public struct MatrixRoomCreateEvent : MatrixStateEventType {
34+ public init (
35+ creator: MatrixFullUserIdentifier ,
36+ federate: Bool ? = nil ,
37+ predecessor: MatrixRoomCreateEvent . PreviousRoom ? = nil ,
38+ roomVersion: String ? = nil ,
39+ roomType: String ? = nil
40+ ) {
41+ self . creator = creator
42+ self . federate = federate
43+ self . predecessor = predecessor
44+ self . roomVersion = roomVersion
45+ self . roomType = roomType
46+ }
47+
3448 public static let type = " m.room.create "
3549
3650 /// The ``MatrixFullUserIdentifier`` of the room creator.
@@ -54,7 +68,7 @@ public struct MatrixRoomCreateEvent: MatrixStateEventType {
5468 /// Unspecified room types are possible using Namespaced Identifiers.
5569 public var roomType : String ?
5670
57- public struct PreviousRoom : Codable {
71+ public struct PreviousRoom : Codable , Equatable , Hashable {
5872 /// The event ID of the last known event in the old room.
5973 public var eventID : String
6074
Original file line number Diff line number Diff line change @@ -12,6 +12,6 @@ public protocol MatrixStoreRoomState {
1212 var eventId : String { get }
1313 var roomId : String { get }
1414 var stateKey : String { get }
15- var contentType : String { get }
15+ var sender : MatrixFullUserIdentifier ? { get }
1616 var content : MatrixStateEventType { get }
1717}
You can’t perform that action at this time.
0 commit comments