refactor: Make file events more fail safe for failed to send

This commit is contained in:
Christian Kußowski 2026-03-09 17:01:11 +01:00
commit fc7eb6954c
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
2 changed files with 9 additions and 7 deletions

View file

@ -165,11 +165,11 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
: null,
);
if (!kIsWeb) {
final attachmentUrl = widget.event.attachmentOrThumbnailMxcUrl();
if (!kIsWeb && attachmentUrl != null) {
final tempDir = await getTemporaryDirectory();
final fileName = Uri.encodeComponent(
widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
);
final fileName = Uri.encodeComponent(attachmentUrl.pathSegments.last);
file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
await file.writeAsBytes(matrixFile.bytes);