diff --git a/snikket/Chat.hx b/snikket/Chat.hx index 3359174..58cc060 100644 --- a/snikket/Chat.hx +++ b/snikket/Chat.hx @@ -1281,20 +1281,20 @@ class SerializedChat { public final avatarSha1:Null; public final presence:Map; public final displayName:Null; - public final uiState:String; + public final uiState:UiState; public final extensions:String; public final readUpToId:Null; public final readUpToBy:Null; public final disco:Null; public final klass:String; - public function new(chatId: String, trusted: Bool, avatarSha1: Null, presence: Map, displayName: Null, uiState: Null, extensions: Null, readUpToId: Null, readUpToBy: Null, disco: Null, klass: String) { + public function new(chatId: String, trusted: Bool, avatarSha1: Null, presence: Map, displayName: Null, uiState: Null, extensions: Null, readUpToId: Null, readUpToBy: Null, disco: Null, klass: String) { this.chatId = chatId; this.trusted = trusted; this.avatarSha1 = avatarSha1; this.presence = presence; this.displayName = displayName; - this.uiState = uiState ?? "Open"; + this.uiState = uiState ?? Open; this.extensions = extensions ?? ""; this.readUpToId = readUpToId; this.readUpToBy = readUpToBy; @@ -1303,18 +1303,12 @@ class SerializedChat { } public function toChat(client: Client, stream: GenericStream, persistence: Persistence) { - final uiStateEnum = switch (uiState) { - case "Pinned": Pinned; - case "Closed": Closed; - default: Open; - } - final extensionsStanza = Stanza.fromXml(Xml.parse(extensions)); final chat = if (klass == "DirectChat") { - new DirectChat(client, stream, persistence, chatId, uiStateEnum, extensionsStanza, readUpToId, readUpToBy); + new DirectChat(client, stream, persistence, chatId, uiState, extensionsStanza, readUpToId, readUpToBy); } else if (klass == "Channel") { - final channel = new Channel(client, stream, persistence, chatId, uiStateEnum, extensionsStanza, readUpToId, readUpToBy); + final channel = new Channel(client, stream, persistence, chatId, uiState, extensionsStanza, readUpToId, readUpToBy); channel.disco = disco ?? new Caps("", [], ["http://jabber.org/protocol/muc"]); channel; } else {