Fixed device vanishing while still being there in the case the device is blacklisted from starting a relay.

This commit is contained in:
Koen J 2025-05-07 15:43:28 +02:00
commit 5be92052bb
2 changed files with 9 additions and 3 deletions

View file

@ -54,7 +54,6 @@ class SyncHomeActivity : AppCompatActivity() {
val view = _viewMap[publicKey]
if (!session.isAuthorized) {
if (view != null) {
_layoutDevices.removeView(view)
_viewMap.remove(publicKey)
}
return@launch
@ -108,11 +107,12 @@ class SyncHomeActivity : AppCompatActivity() {
private fun updateDeviceView(syncDeviceView: SyncDeviceView, publicKey: String, session: SyncSession?): SyncDeviceView {
val connected = session?.connected ?: false
val authorized = session?.isAuthorized ?: false
syncDeviceView.setLinkType(session?.linkType ?: LinkType.None)
.setName(session?.displayName ?: StateSync.instance.getCachedName(publicKey) ?: publicKey)
//TODO: also display public key?
.setStatus(if (connected) "Connected" else "Disconnected")
.setStatus(if (connected && authorized) "Connected" else "Disconnected or unauthorized")
return syncDeviceView
}

View file

@ -1,6 +1,7 @@
package com.futo.platformplayer.stores
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.states.StateApp
import com.futo.platformplayer.stores.v2.JsonStoreSerializer
import com.futo.platformplayer.stores.v2.ManagedStore
import com.futo.platformplayer.stores.v2.StoreSerializer
@ -123,9 +124,14 @@ class FragmentedStorage {
return loadFile(storageFile, storageBakFile);
}
inline fun <reified T> load(fileName: String): T where T : FragmentedStorageFile {
if (_filesDir == null) {
if(StateApp.instance.contextOrNull == null)
StateApp.instance.initializeFiles();
if (_filesDir == null) {
throw Exception("Files dir should be initialized before loading a file.")
}
}
val storageFile = File(_filesDir, "${fileName}.json");
val storageBakFile = File(_filesDir, "${fileName}.json.bak");