status-lib/status/statusgo_backend/gif.nim

20 lines
730 B
Nim
Raw Normal View History

import json, sequtils
2021-09-08 18:05:39 +00:00
import ./settings
import ../types/[setting, gif_item]
2021-09-08 18:05:39 +00:00
proc getRecentGifs*(): seq[GifItem] =
let node = settings.getSetting[JsonNode](Setting.Gifs_Recent, %*{})
return map(node{"items"}.getElems(), settingToGifItem)
2021-09-08 18:05:39 +00:00
proc getFavoriteGifs*(): seq[GifItem] =
let node = settings.getSetting[JsonNode](Setting.Gifs_Favorite, %*{})
return map(node{"items"}.getElems(), settingToGifItem)
2021-09-08 18:05:39 +00:00
proc setFavoriteGifs*(gifItems: seq[GifItem]) =
let node = %*{"items": map(gifItems, toJsonNode)}
discard settings.saveSetting(Setting.Gifs_Favorite, node)
2021-09-08 18:05:39 +00:00
proc setRecentGifs*(gifItems: seq[GifItem]) =
let node = %*{"items": map(gifItems, toJsonNode)}
discard settings.saveSetting(Setting.Gifs_Recent, node)