mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Fix crash when recording long voice message.
This commit is contained in:
+4
-1
@@ -192,7 +192,10 @@ class DefaultVoiceMessageComposerPresenter(
|
|||||||
voiceMessageState = when (val state = recorderState) {
|
voiceMessageState = when (val state = recorderState) {
|
||||||
is VoiceRecorderState.Recording -> VoiceMessageState.Recording(
|
is VoiceRecorderState.Recording -> VoiceMessageState.Recording(
|
||||||
duration = state.elapsedTime,
|
duration = state.elapsedTime,
|
||||||
levels = state.levels.toImmutableList(),
|
levels = state.levels
|
||||||
|
// Keep only the last 128 samples for display, else we can have a crash
|
||||||
|
.takeLast(128)
|
||||||
|
.toImmutableList(),
|
||||||
)
|
)
|
||||||
is VoiceRecorderState.Finished ->
|
is VoiceRecorderState.Finished ->
|
||||||
previewState(
|
previewState(
|
||||||
|
|||||||
+4
-1
@@ -299,7 +299,10 @@ fun TextComposer(
|
|||||||
onSeek = onSeekVoiceMessage,
|
onSeek = onSeekVoiceMessage,
|
||||||
)
|
)
|
||||||
is VoiceMessageState.Recording ->
|
is VoiceMessageState.Recording ->
|
||||||
VoiceMessageRecording(voiceMessageState.levels, voiceMessageState.duration)
|
VoiceMessageRecording(
|
||||||
|
levels = voiceMessageState.levels,
|
||||||
|
duration = voiceMessageState.duration,
|
||||||
|
)
|
||||||
VoiceMessageState.Idle -> {}
|
VoiceMessageState.Idle -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ fun LiveWaveformView(
|
|||||||
|
|
||||||
var parentWidth by remember { mutableIntStateOf(0) }
|
var parentWidth by remember { mutableIntStateOf(0) }
|
||||||
|
|
||||||
val waveformWidth by remember(levels, lineWidth, linePadding) {
|
val waveformWidth by remember(levels.size, lineWidth, linePadding) {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
levels.size * (lineWidth.value + linePadding.value)
|
levels.size * (lineWidth.value + linePadding.value)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ internal fun VoiceMessageRecording(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(26.dp)
|
.height(26.dp)
|
||||||
.weight(1f),
|
.weight(1f),
|
||||||
levels = levels
|
levels = levels,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user