fix cache bug where fresh installs include 1 null recent sticker

This commit is contained in:
Kieran W 2025-02-17 19:21:11 +00:00
parent 43cda5728e
commit 713c51009a
2 changed files with 5 additions and 3 deletions

View File

@ -506,7 +506,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
* @param sticker: File
*/
override fun onStickerClicked(sticker: File) {
this.recentCache.add(sticker.absolutePath)
this.recentCache.add(sticker.path)
this.stickerSender.sendSticker(sticker)
}

View File

@ -5,7 +5,7 @@ import java.util.ArrayDeque
import java.util.Deque
/**
* Basically this behaved like an ordered set with some maximum capacity. When this capacity is
* Basically this behaves like an ordered set with some maximum capacity. When this capacity is
* exceeded an element is removed from the start
*/
class Cache(private val capacity: Int = 30) {
@ -49,6 +49,8 @@ class Cache(private val capacity: Int = 30) {
/** convert from a string (shared-pref) to this */
fun fromSharedPref(raw: String) {
data.clear()
data.addAll(raw.split("\n"))
if (raw.trim().isNotEmpty()) {
data.addAll(raw.split("\n"))
}
}
}