Skip to content

Commit

Permalink
fixup! fixup! TW-1573: change params of getFileEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn committed Apr 10, 2024
1 parent 1c1b23b commit 2df6dcc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/src/database/database_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ abstract class DatabaseApi {
int? limit,
});

Future<Uint8List?> getFile(Uri mxcUri);
Future<Uint8List?> getFile(String eventId, String fileName);

Future<File?> getFileEntity(String eventId, String fileName);

Expand Down
2 changes: 1 addition & 1 deletion lib/src/database/hive_collections_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class HiveCollectionsDatabase extends DatabaseApi {
});

@override
Future<Uint8List?> getFile(Uri mxcUri) async {
Future<Uint8List?> getFile(String eventId, String fileName) async {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/database/hive_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
});

@override
Future<Uint8List?> getFile(Uri mxcUri) async {
Future<Uint8List?> getFile(String eventId, String fileName) async {
return null;
}

Expand Down
12 changes: 10 additions & 2 deletions lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class Event extends MatrixEvent {

Uint8List? uint8list;
if (storeable) {
uint8list = await database.getFile(mxcUrl);
uint8list = await database.getFile(eventId, getThumbnail ? thumbnailFilename : filename);
}
return uint8list != null;
}
Expand Down Expand Up @@ -623,7 +623,7 @@ class Event extends MatrixEvent {

Uint8List? uint8list;
if (storeable) {
uint8list = await room.client.database?.getFile(mxcUrl);
uint8list = await room.client.database?.getFile(eventId, getThumbnail ? thumbnailFilename : filename);
}

// Download the file
Expand Down Expand Up @@ -663,6 +663,14 @@ class Event extends MatrixEvent {
return MatrixFile(bytes: uint8list, name: body);
}

String get thumbnailFilename {
return 'thumbnail-$filename';
}

String get filename {
return (content.tryGet<String>('filename') ?? body);
}

/// Returns if this is a known event type.
bool get isEventTypeKnown =>
EventLocalizations.localizationsMap.containsKey(type);
Expand Down

0 comments on commit 2df6dcc

Please sign in to comment.