re-enabled code related to recent updates to matrix SDK
This commit is contained in:
parent
c91391b274
commit
85b501e180
3 changed files with 76 additions and 77 deletions
|
|
@ -6,11 +6,14 @@ import 'package:archive/archive.dart'
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:fluffychat/utils/client_manager.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dart';
|
||||
import 'package:fluffychat/widgets/app_lock.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' hide Client;
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import '../../widgets/matrix.dart';
|
||||
|
|
@ -315,42 +318,41 @@ class EmotesSettingsController extends State<EmotesSettings> {
|
|||
}
|
||||
|
||||
Future<void> exportAsZip() async {
|
||||
// TODO update matrix SDK to support this
|
||||
// final client = Matrix.of(context).client;
|
||||
final client = Matrix.of(context).client;
|
||||
|
||||
// await showFutureLoadingDialog(
|
||||
// context: context,
|
||||
// future: () async {
|
||||
// final pack = _getPack();
|
||||
// final archive = Archive();
|
||||
// for (final entry in pack.images.entries) {
|
||||
// final emote = entry.value;
|
||||
// final name = entry.key;
|
||||
// final url = await emote.url.getDownloadUri(client);
|
||||
// final response = await get(
|
||||
// url,
|
||||
// headers: {'authorization': 'Bearer ${client.accessToken}'},
|
||||
// );
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
final pack = _getPack();
|
||||
final archive = Archive();
|
||||
for (final entry in pack.images.entries) {
|
||||
final emote = entry.value;
|
||||
final name = entry.key;
|
||||
final url = await emote.url.getDownloadUri(client);
|
||||
final response = await get(
|
||||
url,
|
||||
headers: {'authorization': 'Bearer ${client.accessToken}'},
|
||||
);
|
||||
|
||||
// archive.addFile(
|
||||
// ArchiveFile(
|
||||
// name,
|
||||
// response.bodyBytes.length,
|
||||
// response.bodyBytes,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// final fileName =
|
||||
// '${pack.pack.displayName ?? client.userID?.localpart ?? 'emotes'}.zip';
|
||||
// final output = ZipEncoder().encode(archive);
|
||||
archive.addFile(
|
||||
ArchiveFile(
|
||||
name,
|
||||
response.bodyBytes.length,
|
||||
response.bodyBytes,
|
||||
),
|
||||
);
|
||||
}
|
||||
final fileName =
|
||||
'${pack.pack.displayName ?? client.userID?.localpart ?? 'emotes'}.zip';
|
||||
final output = ZipEncoder().encode(archive);
|
||||
|
||||
// if (output == null) return;
|
||||
if (output == null) return;
|
||||
|
||||
// MatrixFile(
|
||||
// name: fileName,
|
||||
// bytes: Uint8List.fromList(output),
|
||||
// ).save(context);
|
||||
// },
|
||||
// );
|
||||
MatrixFile(
|
||||
name: fileName,
|
||||
bytes: Uint8List.fromList(output),
|
||||
).save(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,45 +11,43 @@ extension ClientDownloadContentExtension on Client {
|
|||
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;
|
||||
// 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 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 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;
|
||||
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);
|
||||
await database?.storeFile(cacheKey, remoteData, 0);
|
||||
|
||||
// return remoteData;
|
||||
// TODO update matrix SDK to support this
|
||||
return Uint8List.fromList([]);
|
||||
return remoteData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,14 +62,13 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
isThumbnail: true,
|
||||
);
|
||||
|
||||
// TODO replace after upgrading matrix SDK
|
||||
// thumbnailUri =
|
||||
// await event.senderFromMemoryOrFallback.avatarUrl?.getThumbnailUri(
|
||||
// client,
|
||||
// width: size,
|
||||
// height: size,
|
||||
// method: thumbnailMethod,
|
||||
// );
|
||||
thumbnailUri =
|
||||
await event.senderFromMemoryOrFallback.avatarUrl?.getThumbnailUri(
|
||||
client,
|
||||
width: size,
|
||||
height: size,
|
||||
method: thumbnailMethod,
|
||||
);
|
||||
}
|
||||
|
||||
_audioPlayer.play();
|
||||
|
|
@ -77,7 +76,7 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
html.Notification(
|
||||
title,
|
||||
body: body,
|
||||
// icon: thumbnailUri?.toString(),
|
||||
icon: thumbnailUri?.toString(),
|
||||
tag: event.room.id,
|
||||
);
|
||||
} else if (Platform.isLinux) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue