mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 15:46:09 +00:00
Show the last app list at once when the Apps tab opens again
The list is still reloaded in the background on every visit; it no longer starts from the loading placeholder each time.
This commit is contained in:
@@ -80,6 +80,10 @@ private class AppItem(val label: String, val packageName: String, val group: App
|
||||
// Decoded icons survive scrolling and tab switches instead of being rendered again every time
|
||||
private val IconCache = LruCache<String, ImageBitmap>(256)
|
||||
|
||||
// Shown right away when the tab opens again, while the list is read anew in the background.
|
||||
// Only touched on the main thread.
|
||||
private var lastAppList: List<AppItem>? = null
|
||||
|
||||
@Composable
|
||||
fun AppsScreen(modifier: Modifier = Modifier) {
|
||||
val context = LocalContext.current
|
||||
@@ -87,7 +91,7 @@ fun AppsScreen(modifier: Modifier = Modifier) {
|
||||
val active by DohVpnService.active.collectAsStateWithLifecycle()
|
||||
val activeExcluded by DohVpnService.activeExcluded.collectAsStateWithLifecycle()
|
||||
|
||||
var apps by remember { mutableStateOf<List<AppItem>?>(null) }
|
||||
var apps by remember { mutableStateOf(lastAppList) }
|
||||
var excluded by remember { mutableStateOf(prefs.excludedApps) }
|
||||
var search by rememberSaveable { mutableStateOf("") }
|
||||
var collapsed by remember { mutableStateOf(setOf(AppGroup.SYSTEM)) }
|
||||
@@ -100,7 +104,7 @@ fun AppsScreen(modifier: Modifier = Modifier) {
|
||||
val searching = search.isNotBlank()
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
apps = withContext(Dispatchers.IO) { loadApps(context) }
|
||||
apps = withContext(Dispatchers.IO) { loadApps(context) }.also { lastAppList = it }
|
||||
}
|
||||
|
||||
val groups = remember(apps, search) {
|
||||
|
||||
Reference in New Issue
Block a user