feat: Better image sending experience

This commit is contained in:
Christian Pauly 2022-03-30 11:46:24 +02:00
parent 8f56687d43
commit 35a2f95eae
6 changed files with 17 additions and 18 deletions

View File

@ -414,10 +414,10 @@ class ChatController extends State<Chat> {
bytes: audioFile.readAsBytesSync(),
name: audioFile.path,
);
await showFutureLoadingDialog(
context: context,
future: () =>
room!.sendFileEvent(file, inReplyTo: replyEvent, extraContent: {
await room!.sendFileEvent(
file,
inReplyTo: replyEvent,
extraContent: {
'info': {
...file.info,
'duration': result.duration,
@ -427,7 +427,7 @@ class ChatController extends State<Chat> {
'duration': result.duration,
'waveform': result.waveform,
},
}),
},
);
setState(() {
replyEvent = null;

View File

@ -290,6 +290,8 @@ class Message extends StatelessWidget {
)),
),
row,
if (event.fileSendingStatus != null)
Text(event.fileSendingStatus!.name),
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction))
Padding(
padding: EdgeInsets.only(

View File

@ -31,20 +31,16 @@ class _SendFileDialogState extends State<SendFileDialog> {
Future<void> _send() async {
var file = widget.file;
MatrixImageFile? thumbnail;
if (file is MatrixImageFile &&
!origImage &&
file.bytes.length > minSizeToCompress) {
file = await MatrixImageFile.shrink(
bytes: file.bytes,
name: file.name,
compute: widget.room.client.runInBackground,
);
}
if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) {
file = await file.resizeVideo();
thumbnail = await file.getVideoThumbnail();
}
await widget.room.sendFileEvent(file, thumbnail: thumbnail);
widget.room.sendFileEvent(
file,
thumbnail: thumbnail,
shrinkImageMaxDimension: origImage ? null : 1600,
);
return;
}
@override

View File

@ -76,7 +76,8 @@ extension LocalizedBody on Event {
Future<MatrixFile?> downloadAndDecryptAttachmentCached(
{bool getThumbnail = false}) async {
final mxcUrl =
attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail).toString();
attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail)?.toString() ??
eventId;
_downloadAndDecryptFutures[mxcUrl] ??= downloadAndDecryptAttachment(
getThumbnail: getThumbnail,
downloadCallback: (Uri url) async {

View File

@ -976,7 +976,7 @@ packages:
name: matrix
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.14"
version: "0.8.15"
matrix_api_lite:
dependency: transitive
description:

View File

@ -57,7 +57,7 @@ dependencies:
keyboard_shortcuts: ^0.1.4
localstorage: ^4.0.0+1
lottie: ^1.2.2
matrix: ^0.8.14
matrix: ^0.8.15
matrix_link_text: ^1.0.2
open_noti_settings: ^0.4.0
package_info_plus: ^1.3.0