mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 06:52:35 +01:00
Merge branch 'krille/send-file' into 'main'
chore: Display error message on file See merge request famedly/fluffychat!797
This commit is contained in:
commit
2f1dc8dc15
@ -290,8 +290,6 @@ class Message extends StatelessWidget {
|
|||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
row,
|
row,
|
||||||
if (event.fileSendingStatus != null)
|
|
||||||
Text(event.fileSendingStatus!.name),
|
|
||||||
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction))
|
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction))
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
|
@ -23,7 +23,6 @@ class SendFileDialog extends StatefulWidget {
|
|||||||
|
|
||||||
class _SendFileDialogState extends State<SendFileDialog> {
|
class _SendFileDialogState extends State<SendFileDialog> {
|
||||||
bool origImage = false;
|
bool origImage = false;
|
||||||
bool _isSending = false;
|
|
||||||
|
|
||||||
/// Images smaller than 20kb don't need compression.
|
/// Images smaller than 20kb don't need compression.
|
||||||
static const int minSizeToCompress = 20 * 1024;
|
static const int minSizeToCompress = 20 * 1024;
|
||||||
@ -32,14 +31,27 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||||||
var file = widget.file;
|
var file = widget.file;
|
||||||
MatrixImageFile? thumbnail;
|
MatrixImageFile? thumbnail;
|
||||||
if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) {
|
if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) {
|
||||||
file = await file.resizeVideo();
|
await showFutureLoadingDialog(
|
||||||
thumbnail = await file.getVideoThumbnail();
|
context: context,
|
||||||
|
future: () async {
|
||||||
|
file = await file.resizeVideo();
|
||||||
|
thumbnail = await file.getVideoThumbnail();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
widget.room.sendFileEvent(
|
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||||
|
widget.room
|
||||||
|
.sendFileEvent(
|
||||||
file,
|
file,
|
||||||
thumbnail: thumbnail,
|
thumbnail: thumbnail,
|
||||||
shrinkImageMaxDimension: origImage ? null : 1600,
|
shrinkImageMaxDimension: origImage ? null : 1600,
|
||||||
);
|
)
|
||||||
|
.catchError((e) {
|
||||||
|
scaffoldMessenger.showSnackBar(
|
||||||
|
SnackBar(content: Text(e.toLocalizedString())),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Navigator.of(context, rootNavigator: false).pop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,16 +103,7 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||||||
child: Text(L10n.of(context)!.cancel),
|
child: Text(L10n.of(context)!.cancel),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _isSending
|
onPressed: _send,
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
setState(() {
|
|
||||||
_isSending = true;
|
|
||||||
});
|
|
||||||
await showFutureLoadingDialog(
|
|
||||||
context: context, future: () => _send());
|
|
||||||
Navigator.of(context, rootNavigator: false).pop();
|
|
||||||
},
|
|
||||||
child: Text(L10n.of(context)!.send),
|
child: Text(L10n.of(context)!.send),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user