| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2024-11-07 05:18:58 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2024-11-07 05:18:58 UTC |
| parent | bccccd806ae7555d27b06bd60545b1b92fcad525 |
| snikket/Client.hx | +3 | -2 |
diff --git a/snikket/Client.hx b/snikket/Client.hx index 2ecae2e..8eaf571 100644 --- a/snikket/Client.hx +++ b/snikket/Client.hx @@ -1110,10 +1110,11 @@ class Client extends EventEmitter { chat.uiState = Open; persistence.storeChat(accountId(), chat); } + final pinnedCount = chat.uiState == Pinned ? 0 : chats.fold((item, result) -> result + (item.uiState == Pinned ? 1 : 0), 0); var idx = chats.indexOf(chat); - if (idx > 0) { + if (idx > pinnedCount) { chats.splice(idx, 1); - chats.unshift(chat); + chats.insert(pinnedCount, chat); if (trigger) this.trigger("chats/update", [chat]); } }