You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
Dart
56 lines
1.5 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
extension ClientDownloadContentExtension on Client {
|
|
Future<Uint8List> downloadMxcCached(
|
|
Uri mxc, {
|
|
num? width,
|
|
num? height,
|
|
bool isThumbnail = false,
|
|
bool? animated,
|
|
ThumbnailMethod? thumbnailMethod,
|
|
}) async {
|
|
// // To stay compatible with previous storeKeys:
|
|
// final cacheKey = isThumbnail
|
|
// // ignore: deprecated_member_use
|
|
// ? mxc.getThumbnail(
|
|
// this,
|
|
// width: width,
|
|
// height: height,
|
|
// animated: animated,
|
|
// method: thumbnailMethod!,
|
|
// )
|
|
// : mxc;
|
|
|
|
// final cachedData = await database?.getFile(cacheKey);
|
|
// if (cachedData != null) return cachedData;
|
|
|
|
// final httpUri = isThumbnail
|
|
// ? await mxc.getThumbnailUri(
|
|
// this,
|
|
// width: width,
|
|
// height: height,
|
|
// animated: animated,
|
|
// method: thumbnailMethod,
|
|
// )
|
|
// : await mxc.getDownloadUri(this);
|
|
|
|
// final response = await httpClient.get(
|
|
// httpUri,
|
|
// headers:
|
|
// accessToken == null ? null : {'authorization': 'Bearer $accessToken'},
|
|
// );
|
|
// if (response.statusCode != 200) {
|
|
// throw Exception();
|
|
// }
|
|
// final remoteData = response.bodyBytes;
|
|
|
|
// await database?.storeFile(cacheKey, remoteData, 0);
|
|
|
|
// return remoteData;
|
|
// TODO update matrix SDK to support this
|
|
return Uint8List.fromList([]);
|
|
}
|
|
}
|