perf(prefs): разбор серверов только при их изменении
This commit is contained in:
1 parent
bba32ea051
commit
017876d62e
1 file changed
+10
-7
@@ -90,13 +90,16 @@ class AppPreferences(context: Context) {
|
|||||||
.catch { if (it is IOException) emit(emptyPreferences()) else throw it }
|
.catch { if (it is IOException) emit(emptyPreferences()) else throw it }
|
||||||
.map(transform)
|
.map(transform)
|
||||||
|
|
||||||
val serversSnapshot: Flow<ServersSnapshot> = prefFlow { prefs ->
|
val serversSnapshot: Flow<ServersSnapshot> =
|
||||||
ServersSnapshot(
|
prefFlow { prefs -> prefs[SERVERS_JSON] to prefs[ACTIVE_SERVER_ID] }
|
||||||
list = ServerJson.decodeList(prefs[SERVERS_JSON]),
|
.distinctUntilChanged()
|
||||||
activeId = prefs[ACTIVE_SERVER_ID]?.takeIf { it.isNotBlank() },
|
.map { (json, activeId) ->
|
||||||
loaded = true
|
ServersSnapshot(
|
||||||
)
|
list = ServerJson.decodeList(json),
|
||||||
}
|
activeId = activeId?.takeIf { it.isNotBlank() },
|
||||||
|
loaded = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Производные от serversSnapshot: их читает рантайм (ProxyService, оркестратор,
|
// Производные от serversSnapshot: их читает рантайм (ProxyService, оркестратор,
|
||||||
// SSH). Без активного сервера отдают дефолты - запускать в этом случае нечего.
|
// SSH). Без активного сервера отдают дефолты - запускать в этом случае нечего.
|
||||||
|
|||||||
Reference in new issue
Block a user