Skip to content

Commit 5cd0e12

Browse files
committed
fixup: Fix the Notification show Not Connected
1 parent 8889da5 commit 5cd0e12

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

app/src/main/java/com/sameerasw/airsync/utils/ServiceManager.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ object ServiceManager {
3636
fun updateServiceState(context: Context) {
3737
CoroutineScope(Dispatchers.IO).launch {
3838
if (shouldServiceRun(context)) {
39-
AirSyncService.startScanning(context)
39+
if (WebSocketUtil.isConnected()) {
40+
// If already connected, start in sync mode so the notification correctly shows "Connected to X"
41+
val dataStore = DataStoreManager.getInstance(context)
42+
val lastDevice = dataStore.getLastConnectedDevice().first()
43+
AirSyncService.start(context, lastDevice?.name)
44+
} else {
45+
AirSyncService.startScanning(context)
46+
}
4047
} else {
4148
AirSyncService.stop(context)
4249
}

0 commit comments

Comments
 (0)