fix: order of recent stickers incorrect on app start

Order of recent stickers was being loaded in reverse order.
This commit is contained in:
emizzle 2020-06-29 19:11:21 +10:00 committed by Iuri Matias
parent 8e6eb65509
commit f54d66bf24
3 changed files with 9 additions and 6 deletions

View File

@ -153,16 +153,17 @@ proc sendMessage*(self: ChatModel, chatId: string, msg: string): string =
self.emitUpdate(sentMessage)
sentMessage
proc addStickerToRecent*(self: ChatModel, sticker: Sticker) =
proc addStickerToRecent*(self: ChatModel, sticker: Sticker, save: bool = false) =
self.recentStickers.insert(sticker, 0)
self.recentStickers = self.recentStickers.deduplicate()
if self.recentStickers.len > 24:
self.recentStickers = self.recentStickers[0..23] # take top 24 most recent
status_stickers.saveRecentStickers(self.recentStickers)
if save:
status_stickers.saveRecentStickers(self.recentStickers)
proc sendSticker*(self: ChatModel, chatId: string, sticker: Sticker) =
var response = status_chat.sendStickerMessage(chatId, sticker)
self.addStickerToRecent(sticker)
self.addStickerToRecent(sticker, save = true)
self.emitUpdate(response)
proc chatMessages*(self: ChatModel, chatId: string, initialLoad:bool = true) =

View File

@ -3,7 +3,7 @@ import json, tables
import json_serialization
var settings: JsonNode = %*{}
var dirty: bool = false
var dirty: bool = true
proc saveSettings*(key: string, value: string | JsonNode): StatusGoError =
let response = callPrivateRPC("settings_saveSetting", %* [

File diff suppressed because one or more lines are too long