mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-11 06:47:01 +00:00
fix: introduce chat types for Timeline and Profile
When dealing with Timeline and Profile chat data, the `HEAD~1` would break because we're trying to access `ChatType(4)` inside our `toChat` API. To fix this issue, we have to make `ChatType` aware of `4` and `5` which are `Profile` and `Timeline` respectively.
This commit is contained in:
parent
3258ac8f9c
commit
4354ee15ed
@ -5,7 +5,9 @@ type ChatType* {.pure.}= enum
|
||||
Unknown = 0,
|
||||
OneToOne = 1,
|
||||
Public = 2,
|
||||
PrivateGroupChat = 3
|
||||
PrivateGroupChat = 3,
|
||||
Profile = 4,
|
||||
Timeline = 5
|
||||
|
||||
proc isOneToOne*(self: ChatType): bool = self == ChatType.OneToOne
|
||||
|
||||
|
@ -109,13 +109,17 @@ proc newChat*(id: string, chatType: ChatType): Chat =
|
||||
result.name = id
|
||||
|
||||
proc toChat*(jsonChat: JsonNode): Chat =
|
||||
|
||||
let chatTypeInt = jsonChat{"chatType"}.getInt
|
||||
let chatType: ChatType = if chatTypeInt >= ord(low(ChatType)) or chatTypeInt <= ord(high(ChatType)): ChatType(chatTypeInt) else: ChatType.Unknown
|
||||
|
||||
result = Chat(
|
||||
id: jsonChat{"id"}.getStr,
|
||||
name: jsonChat{"name"}.getStr,
|
||||
identicon: "",
|
||||
color: jsonChat{"color"}.getStr,
|
||||
isActive: jsonChat{"active"}.getBool,
|
||||
chatType: ChatType(jsonChat{"chatType"}.getInt),
|
||||
chatType: chatType,
|
||||
timestamp: jsonChat{"timestamp"}.getBiggestInt,
|
||||
lastClockValue: jsonChat{"lastClockValue"}.getBiggestInt,
|
||||
deletedAtClockValue: jsonChat{"deletedAtClockValue"}.getBiggestInt,
|
||||
|
Loading…
x
Reference in New Issue
Block a user