refactor: Make file events more fail safe for failed to send
This commit is contained in:
parent
084801fd84
commit
fc7eb6954c
2 changed files with 9 additions and 7 deletions
|
|
@ -165,11 +165,11 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!kIsWeb) {
|
final attachmentUrl = widget.event.attachmentOrThumbnailMxcUrl();
|
||||||
|
|
||||||
|
if (!kIsWeb && attachmentUrl != null) {
|
||||||
final tempDir = await getTemporaryDirectory();
|
final tempDir = await getTemporaryDirectory();
|
||||||
final fileName = Uri.encodeComponent(
|
final fileName = Uri.encodeComponent(attachmentUrl.pathSegments.last);
|
||||||
widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
|
|
||||||
);
|
|
||||||
file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
|
file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
|
||||||
|
|
||||||
await file.writeAsBytes(matrixFile.bytes);
|
await file.writeAsBytes(matrixFile.bytes);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
|
import 'package:async/async.dart' show Result;
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:cross_file/cross_file.dart';
|
import 'package:cross_file/cross_file.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart' hide Result;
|
||||||
import 'package:mime/mime.dart';
|
import 'package:mime/mime.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
|
@ -53,8 +54,9 @@ class SendFileDialogState extends State<SendFileDialog> {
|
||||||
}
|
}
|
||||||
scaffoldMessenger.showLoadingSnackBar(l10n.prepareSendingAttachment);
|
scaffoldMessenger.showLoadingSnackBar(l10n.prepareSendingAttachment);
|
||||||
Navigator.of(context, rootNavigator: false).pop();
|
Navigator.of(context, rootNavigator: false).pop();
|
||||||
final clientConfig = await widget.room.client.getConfig();
|
final clientConfig = await Result.capture(widget.room.client.getConfig());
|
||||||
final maxUploadSize = clientConfig.mUploadSize ?? 100 * 1000 * 1000;
|
final maxUploadSize =
|
||||||
|
clientConfig.asValue?.value.mUploadSize ?? 100 * 1000 * 1000;
|
||||||
|
|
||||||
for (final xfile in widget.files) {
|
for (final xfile in widget.files) {
|
||||||
final MatrixFile file;
|
final MatrixFile file;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue