mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-12 18:52:39 +01:00
fix: Analyzer bugs
This commit is contained in:
parent
15fcfbf362
commit
dcee386da4
@ -16,7 +16,7 @@ class ArchiveController extends State<Archive> {
|
|||||||
|
|
||||||
Future<List<Room>> getArchive(BuildContext context) async {
|
Future<List<Room>> getArchive(BuildContext context) async {
|
||||||
if (archive != null) return archive;
|
if (archive != null) return archive;
|
||||||
return await Matrix.of(context).client.archive;
|
return await Matrix.of(context).client.loadArchive();
|
||||||
}
|
}
|
||||||
|
|
||||||
void forgetAction(int i) => setState(() => archive.removeAt(i));
|
void forgetAction(int i) => setState(() => archive.removeAt(i));
|
||||||
|
@ -80,7 +80,7 @@ extension LocalizedBody on Event {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// check if the url is cached
|
// check if the url is cached
|
||||||
final url = Uri.parse(mxcUrl).getDownloadLink(room.client);
|
final url = mxcUrl.getDownloadLink(room.client);
|
||||||
final file = await DefaultCacheManager().getFileFromCache(url.toString());
|
final file = await DefaultCacheManager().getFileFromCache(url.toString());
|
||||||
return file != null;
|
return file != null;
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ extension LocalizedBody on Event {
|
|||||||
Future<MatrixFile> downloadAndDecryptAttachmentCached(
|
Future<MatrixFile> downloadAndDecryptAttachmentCached(
|
||||||
{bool getThumbnail = false}) async {
|
{bool getThumbnail = false}) async {
|
||||||
final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail);
|
final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail);
|
||||||
_downloadAndDecryptFutures[mxcUrl] ??= downloadAndDecryptAttachment(
|
_downloadAndDecryptFutures[mxcUrl.toString()] ??= downloadAndDecryptAttachment(
|
||||||
getThumbnail: getThumbnail,
|
getThumbnail: getThumbnail,
|
||||||
downloadCallback: (Uri url) async {
|
downloadCallback: (Uri url) async {
|
||||||
final file = await DefaultCacheManager().getSingleFile(url.toString());
|
final file = await DefaultCacheManager().getSingleFile(url.toString());
|
||||||
|
@ -118,20 +118,22 @@ class FlutterMatrixHiveStore extends FamedlySdkHiveDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Uint8List> getFile(String mxcUri) async {
|
Future<Uint8List> getFile(Uri mxcUri) async {
|
||||||
if (!supportsFileStoring) return null;
|
if (!supportsFileStoring) return null;
|
||||||
final tempDirectory = await _getFileStoreDirectory();
|
final tempDirectory = await _getFileStoreDirectory();
|
||||||
final file = File('$tempDirectory/${Uri.encodeComponent(mxcUri)}');
|
final file =
|
||||||
|
File('$tempDirectory/${Uri.encodeComponent(mxcUri.toString())}');
|
||||||
if (await file.exists() == false) return null;
|
if (await file.exists() == false) return null;
|
||||||
final bytes = await file.readAsBytes();
|
final bytes = await file.readAsBytes();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future storeFile(String mxcUri, Uint8List bytes, int time) async {
|
Future storeFile(Uri mxcUri, Uint8List bytes, int time) async {
|
||||||
if (!supportsFileStoring) return null;
|
if (!supportsFileStoring) return null;
|
||||||
final tempDirectory = await _getFileStoreDirectory();
|
final tempDirectory = await _getFileStoreDirectory();
|
||||||
final file = File('$tempDirectory/${Uri.encodeComponent(mxcUri)}');
|
final file =
|
||||||
|
File('$tempDirectory/${Uri.encodeComponent(mxcUri.toString())}');
|
||||||
if (await file.exists()) return;
|
if (await file.exists()) return;
|
||||||
await file.writeAsBytes(bytes);
|
await file.writeAsBytes(bytes);
|
||||||
return;
|
return;
|
||||||
|
@ -21,7 +21,7 @@ import 'package:matrix/matrix.dart';
|
|||||||
import 'resize_image.dart';
|
import 'resize_image.dart';
|
||||||
|
|
||||||
extension RoomSendFileExtension on Room {
|
extension RoomSendFileExtension on Room {
|
||||||
Future<String> sendFileEventWithThumbnail(
|
Future<Uri> sendFileEventWithThumbnail(
|
||||||
MatrixFile file, {
|
MatrixFile file, {
|
||||||
String txid,
|
String txid,
|
||||||
Event inReplyTo,
|
Event inReplyTo,
|
||||||
|
@ -265,7 +265,8 @@ class _ImageBubbleState extends State<ImageBubble> {
|
|||||||
: widget.event.thumbnailMxcUrl;
|
: widget.event.thumbnailMxcUrl;
|
||||||
final mimetype = getMimetype(!isOriginal);
|
final mimetype = getMimetype(!isOriginal);
|
||||||
if (_contentRenderers.containsKey(mimetype)) {
|
if (_contentRenderers.containsKey(mimetype)) {
|
||||||
return _contentRenderers[mimetype].memory(_displayFile.bytes, key);
|
return _contentRenderers[mimetype]
|
||||||
|
.memory(_displayFile.bytes, key.toString());
|
||||||
} else {
|
} else {
|
||||||
return Image.memory(
|
return Image.memory(
|
||||||
_displayFile.bytes,
|
_displayFile.bytes,
|
||||||
|
Loading…
Reference in New Issue
Block a user