mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
fix: Add workaround for DisposableEffect
Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
parent
14d6b36162
commit
798b6f2119
@ -291,8 +291,17 @@ fun RecorderEventsHandler(
|
||||
}
|
||||
|
||||
// Register video recorder events
|
||||
// Absolutely no idea, but somehow on some devices the `DisposableEffect`
|
||||
// is registered twice, and THEN disposed once (AFTER being called twice),
|
||||
// which then causes the `onRecordingSave` to be in a weird state.
|
||||
// This variable is a workaround to prevent this from happening.
|
||||
var alreadyRegistered = false
|
||||
DisposableEffect(Unit) {
|
||||
Log.d("Alibi", "===== Registering videoRecorder events $videoRecorder")
|
||||
if (alreadyRegistered) {
|
||||
onDispose { }
|
||||
} else {
|
||||
alreadyRegistered = true
|
||||
Log.i("Alibi", "===== Registering videoRecorder events $videoRecorder")
|
||||
videoRecorder.onRecordingSave = { cleanupOldFiles ->
|
||||
saveRecording(videoRecorder as RecorderModel, cleanupOldFiles)
|
||||
}
|
||||
@ -327,13 +336,14 @@ fun RecorderEventsHandler(
|
||||
}
|
||||
|
||||
onDispose {
|
||||
Log.d("Alibi", "===== Disposing videoRecorder events")
|
||||
Log.i("Alibi", "===== Disposing videoRecorder events")
|
||||
videoRecorder.onRecordingSave = {
|
||||
throw NotImplementedError("onRecordingSave should not be called now")
|
||||
}
|
||||
videoRecorder.onError = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isProcessing)
|
||||
RecorderProcessingDialog(
|
||||
|
Loading…
x
Reference in New Issue
Block a user