Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
fix(android): renaming the phone reaches the PC right away (#87)
Beeffcc3726cf66
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/core/Core.kt b/android/app/src/main/kotlin/app/nectarlink/android/core/Core.ktindex c3f99a6..e62ebee 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/core/Core.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/core/Core.kt@@ -67,6 +67,7 @@ import kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.Jobimport kotlinx.coroutines.cancelAndJoinimport kotlinx.coroutines.channels.Channel+import kotlinx.coroutines.channels.awaitCloseimport kotlinx.coroutines.delayimport kotlinx.coroutines.sync.Muteximport kotlinx.coroutines.sync.withLock@@ -77,6 +78,7 @@ import kotlinx.coroutines.flow.SharingStartedimport kotlinx.coroutines.flow.StateFlowimport kotlinx.coroutines.flow.asSharedFlowimport kotlinx.coroutines.flow.asStateFlow+import kotlinx.coroutines.flow.callbackFlowimport kotlinx.coroutines.flow.combineimport kotlinx.coroutines.flow.distinctUntilChangedimport kotlinx.coroutines.flow.map@@ -466,6 +468,26 @@ class Core(context: Context, private val scope: CoroutineScope) : EventListenerrefreshDataRetention()app.nectarlink.android.clipboard.DirectShareTargets.sync(context, _state.value.devices)app.nectarlink.android.widget.PcWidgetProvider.refreshAll(context, _state.value)+ currentRunScope.launch(Dispatchers.IO) {+ // A rename in Android's settings reaches the PCs right away,+ // not at the next start (#87).+ callbackFlow {+ val observer = object : android.database.ContentObserver(null) {+ override fun onChange(selfChange: Boolean) {+ trySend(Unit)+ }+ }+ context.contentResolver.registerContentObserver(+ android.provider.Settings.Global.getUriFor(android.provider.Settings.Global.DEVICE_NAME),+ false,+ observer,+ )+ awaitClose { context.contentResolver.unregisterContentObserver(observer) }+ }.collect {+ runCatching { started.updateDeviceInfo(deviceInfo(context, _state.value.activeMediaColor)) }+ .onFailure { Log.w(TAG, "can't send the new device name", it) }+ }+ }currentRunScope.launch(Dispatchers.IO) {_state.map { s ->