|
|
@ -135,25 +135,31 @@ class ChatController extends State<ChatPageWithRoom>
|
|
|
|
|
|
|
|
|
|
|
|
void onDragDone(DropDoneDetails details) async {
|
|
|
|
void onDragDone(DropDoneDetails details) async {
|
|
|
|
setState(() => dragging = false);
|
|
|
|
setState(() => dragging = false);
|
|
|
|
final bytesList = await showFutureLoadingDialog(
|
|
|
|
if (details.files.isEmpty) return;
|
|
|
|
|
|
|
|
final result = await showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
future: () => Future.wait(
|
|
|
|
future: () async {
|
|
|
|
details.files.map(
|
|
|
|
final clientConfig = await room.client.getConfig();
|
|
|
|
(xfile) => xfile.readAsBytes(),
|
|
|
|
final maxUploadSize = clientConfig.mUploadSize ?? 100 * 1024 * 1024;
|
|
|
|
),
|
|
|
|
final matrixFiles = await Future.wait(
|
|
|
|
),
|
|
|
|
details.files.map(
|
|
|
|
|
|
|
|
(xfile) async {
|
|
|
|
|
|
|
|
final length = await xfile.length();
|
|
|
|
|
|
|
|
if (length > maxUploadSize) {
|
|
|
|
|
|
|
|
throw FileTooBigMatrixException(length, maxUploadSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return MatrixFile(
|
|
|
|
|
|
|
|
bytes: await xfile.readAsBytes(),
|
|
|
|
|
|
|
|
name: xfile.name,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return matrixFiles;
|
|
|
|
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (bytesList.error != null) return;
|
|
|
|
final matrixFiles = result.result;
|
|
|
|
|
|
|
|
if (matrixFiles == null || matrixFiles.isEmpty) return;
|
|
|
|
final matrixFiles = <MatrixFile>[];
|
|
|
|
|
|
|
|
for (var i = 0; i < bytesList.result!.length; i++) {
|
|
|
|
|
|
|
|
matrixFiles.add(
|
|
|
|
|
|
|
|
MatrixFile(
|
|
|
|
|
|
|
|
bytes: bytesList.result![i],
|
|
|
|
|
|
|
|
name: details.files[i].name,
|
|
|
|
|
|
|
|
).detectFileType,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await showAdaptiveDialog(
|
|
|
|
await showAdaptiveDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|