[optimize] Optimize API call logic, do not create crashes

This commit is contained in:
acite
2025-08-25 17:22:09 +08:00
parent 0398caf3e5
commit 8fa9dfc809
4 changed files with 41 additions and 14 deletions

View File

@@ -50,9 +50,11 @@ object RecentManager
try{
val r = Json.decodeFromString<List<VideoQueryIndex>>(content)
_recent.value = r.map{
val vn = r.map{
MediaManager.queryVideo(it.klass, it.id)
}
}.filter { it != null }
_recent.value = vn.map { it!! }
return r
}catch (e: Exception)
{
@@ -82,9 +84,12 @@ object RecentManager
if(o.size >= 21)
o.removeAt(o.size - 1)
_recent.value = o.map{
val vn = o.map{
MediaManager.queryVideo(it.klass, it.id)
}
}.filter { it != null }
_recent.value = vn.map { it!! }
writeFile(context, "recent.json", Json.encodeToString(o))
}
}