fix: tear down nest session on host Close the Room
The host-leave confirmation dialog's Close the Room button only called finish(), relying on VM.onCleared() to release the AudioRecord. That runs late in the destroy lifecycle, so the system mic-in-use indicator stayed lit while the activity was queued for destruction. Adds NestViewModel.leave(), which mirrors onCleared() (sets closed, runs both teardowns with finalCleanup=true so closes route through cleanupScope/GlobalScope and survive Activity destruction). Wires it into the Close the Room callback only — the Just Leave and non-host Leave paths are unchanged per request.
This commit is contained in:
+18
@@ -545,6 +545,24 @@ class NestViewModel(
|
||||
teardown(targetState = ConnectionUiState.Idle, finalCleanup = false)
|
||||
}
|
||||
|
||||
/**
|
||||
* User-driven leave-the-activity teardown. Mirrors [onCleared]: marks
|
||||
* the VM closed and routes both the speaker handle close (which
|
||||
* releases the AudioRecord and clears the system mic indicator) and
|
||||
* the listener close to [cleanupScope] so the teardown survives
|
||||
* Activity destruction. Call this from the leave-the-room button
|
||||
* BEFORE finishing the activity; relying on [onCleared] alone leaves
|
||||
* a window where the AudioRecord stays held while the activity is
|
||||
* paused / queued for destruction.
|
||||
*/
|
||||
fun leave() {
|
||||
if (closed) return
|
||||
closed = true
|
||||
requestedSpeakers = emptySet()
|
||||
teardownBroadcast(BroadcastUiState.Idle, finalCleanup = true)
|
||||
teardown(targetState = ConnectionUiState.Closed, finalCleanup = true)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
closed = true
|
||||
teardownBroadcast(BroadcastUiState.Idle, finalCleanup = true)
|
||||
|
||||
Reference in New Issue
Block a user