diff --git a/lib/controllers/post_editor_controller.dart b/lib/controllers/post_editor_controller.dart index c2610f8..a4f6cda 100644 --- a/lib/controllers/post_editor_controller.dart +++ b/lib/controllers/post_editor_controller.dart @@ -31,9 +31,9 @@ class PostEditorController extends GetxController { Rx realmZone = Rx(null); Rx publishedAt = Rx(null); Rx publishedUntil = Rx(null); - RxList attachments = RxList.empty(growable: true); + RxList attachments = RxList.empty(growable: true); RxList tags = RxList.empty(growable: true); - Rx thumbnail = Rx(null); + Rx thumbnail = Rx(null); RxList visibleUsers = RxList.empty(growable: true); RxList invisibleUsers = RxList.empty(growable: true); @@ -116,12 +116,12 @@ class PostEditorController extends GetxController { return showModalBottomSheet( context: context, builder: (context) => AttachmentEditorPopup( - usage: 'i.attachment', + pool: 'interactive', initialAttachments: attachments, - onAdd: (int value) { + onAdd: (String value) { attachments.add(value); }, - onRemove: (int value) { + onRemove: (String value) { attachments.remove(value); }, ), @@ -169,6 +169,7 @@ class PostEditorController extends GetxController { } void currentClear() { + aliasController.clear(); titleController.clear(); descriptionController.clear(); contentController.clear(); diff --git a/lib/models/attachment.dart b/lib/models/attachment.dart index f4c7dc3..5df54b6 100644 --- a/lib/models/attachment.dart +++ b/lib/models/attachment.dart @@ -5,11 +5,11 @@ class Attachment { DateTime createdAt; DateTime updatedAt; DateTime? deletedAt; + String rid; String uuid; int size; String name; String alt; - String usage; String mimetype; String hash; int destination; @@ -24,11 +24,11 @@ class Attachment { required this.createdAt, required this.updatedAt, required this.deletedAt, + required this.rid, required this.uuid, required this.size, required this.name, required this.alt, - required this.usage, required this.mimetype, required this.hash, required this.destination, @@ -40,42 +40,45 @@ class Attachment { }); factory Attachment.fromJson(Map json) => Attachment( - id: json['id'], - createdAt: DateTime.parse(json['created_at']), - updatedAt: DateTime.parse(json['updated_at']), - deletedAt: json['deleted_at'] != null ? DateTime.parse(json['deleted_at']) : null, - uuid: json['uuid'], - size: json['size'], - name: json['name'], - alt: json['alt'], - usage: json['usage'], - mimetype: json['mimetype'], - hash: json['hash'], - destination: json['destination'], - isAnalyzed: json['is_analyzed'], - metadata: json['metadata'], - isMature: json['is_mature'], - account: json['account'] != null ? Account.fromJson(json['account']) : null, - accountId: json['account_id'], - ); + id: json['id'], + createdAt: DateTime.parse(json['created_at']), + updatedAt: DateTime.parse(json['updated_at']), + deletedAt: json['deleted_at'] != null + ? DateTime.parse(json['deleted_at']) + : null, + rid: json['rid'], + uuid: json['uuid'], + size: json['size'], + name: json['name'], + alt: json['alt'], + mimetype: json['mimetype'], + hash: json['hash'], + destination: json['destination'], + isAnalyzed: json['is_analyzed'], + metadata: json['metadata'], + isMature: json['is_mature'], + account: + json['account'] != null ? Account.fromJson(json['account']) : null, + accountId: json['account_id'], + ); Map toJson() => { - 'id': id, - 'created_at': createdAt.toIso8601String(), - 'updated_at': updatedAt.toIso8601String(), - 'deleted_at': deletedAt?.toIso8601String(), - 'uuid': uuid, - 'size': size, - 'name': name, - 'alt': alt, - 'usage': usage, - 'mimetype': mimetype, - 'hash': hash, - 'destination': destination, - 'is_analyzed': isAnalyzed, - 'metadata': metadata, - 'is_mature': isMature, - 'account': account?.toJson(), - 'account_id': accountId, - }; -} \ No newline at end of file + 'id': id, + 'created_at': createdAt.toIso8601String(), + 'updated_at': updatedAt.toIso8601String(), + 'deleted_at': deletedAt?.toIso8601String(), + 'rid': rid, + 'uuid': uuid, + 'size': size, + 'name': name, + 'alt': alt, + 'mimetype': mimetype, + 'hash': hash, + 'destination': destination, + 'is_analyzed': isAnalyzed, + 'metadata': metadata, + 'is_mature': isMature, + 'account': account?.toJson(), + 'account_id': accountId, + }; +} diff --git a/lib/providers/attachment_uploader.dart b/lib/providers/attachment_uploader.dart index f02f3d0..e8f643a 100644 --- a/lib/providers/attachment_uploader.dart +++ b/lib/providers/attachment_uploader.dart @@ -148,7 +148,7 @@ class AttachmentUploaderController extends GetxController { Future uploadAttachmentWithCallback( Uint8List data, String path, - String usage, + String pool, Map? metadata, Function(Attachment?) callback, ) async { @@ -158,7 +158,7 @@ class AttachmentUploaderController extends GetxController { final result = await _rawUploadAttachment( data, path, - usage, + pool, metadata, onProgress: (progress) { progressOfUpload.value = progress; @@ -171,7 +171,7 @@ class AttachmentUploaderController extends GetxController { Future uploadAttachment( Uint8List data, String path, - String usage, + String pool, Map? metadata, ) async { if (isUploading.value) throw Exception('uploading blocked'); @@ -180,7 +180,7 @@ class AttachmentUploaderController extends GetxController { final result = await _rawUploadAttachment( data, path, - usage, + pool, metadata, onProgress: (progress) { progressOfUpload.value = progress; @@ -191,14 +191,14 @@ class AttachmentUploaderController extends GetxController { } Future _rawUploadAttachment( - Uint8List data, String path, String usage, Map? metadata, + Uint8List data, String path, String pool, Map? metadata, {Function(double)? onProgress, Function(dynamic err)? onError}) async { final AttachmentProvider provider = Get.find(); try { final result = await provider.createAttachment( data, path, - usage, + pool, metadata, onProgress: onProgress, ); diff --git a/lib/providers/call.dart b/lib/providers/call.dart index 2903f01..0eea97b 100644 --- a/lib/providers/call.dart +++ b/lib/providers/call.dart @@ -88,7 +88,30 @@ class ChatCallProvider extends GetxController { void initRoom() { initHardware(); - room = Room(); + room = Room( + roomOptions: const RoomOptions( + dynacast: true, + adaptiveStream: true, + defaultAudioPublishOptions: AudioPublishOptions( + name: 'call_voice', + stream: 'call_stream', + ), + defaultVideoPublishOptions: VideoPublishOptions( + name: 'call_video', + stream: 'call_stream', + simulcast: true, + backupVideoCodec: BackupVideoCodec(enabled: true), + ), + defaultScreenShareCaptureOptions: ScreenShareCaptureOptions( + useiOSBroadcastExtension: true, + params: VideoParametersPresets.screenShareH1080FPS30, + ), + defaultCameraCaptureOptions: CameraCaptureOptions( + maxFrameRate: 30, + params: VideoParametersPresets.h1080_169, + ), + ), + ); listener = room.createListener(); WakelockPlus.enable(); } @@ -104,28 +127,6 @@ class ChatCallProvider extends GetxController { await room.connect( url, token, - roomOptions: const RoomOptions( - dynacast: true, - adaptiveStream: true, - defaultAudioPublishOptions: AudioPublishOptions( - name: 'call_voice', - stream: 'call_stream', - ), - defaultVideoPublishOptions: VideoPublishOptions( - name: 'call_video', - stream: 'call_stream', - simulcast: true, - backupVideoCodec: BackupVideoCodec(enabled: true), - ), - defaultScreenShareCaptureOptions: ScreenShareCaptureOptions( - useiOSBroadcastExtension: true, - params: VideoParametersPresets.screenShareH1080FPS30, - ), - defaultCameraCaptureOptions: CameraCaptureOptions( - maxFrameRate: 30, - params: VideoParametersPresets.h1080_169, - ), - ), fastConnectOptions: FastConnectOptions( microphone: TrackOption(track: audioTrack.value), camera: TrackOption(track: videoTrack.value), @@ -152,7 +153,7 @@ class ChatCallProvider extends GetxController { void onRoomDidUpdate() => sortParticipants(); void setupRoom() { - if(isInitialized.value) return; + if (isInitialized.value) return; sortParticipants(); room.addListener(onRoomDidUpdate); diff --git a/lib/providers/content/attachment.dart b/lib/providers/content/attachment.dart index 915745b..5ccbf14 100644 --- a/lib/providers/content/attachment.dart +++ b/lib/providers/content/attachment.dart @@ -20,22 +20,22 @@ class AttachmentProvider extends GetConnect { httpClient.baseUrl = ServiceFinder.buildUrl('files', null); } - final Map _cachedResponses = {}; + final Map _cachedResponses = {}; Future> listMetadata( - List id, { + List rid, { noCache = false, }) async { - if (id.isEmpty) return List.empty(); + if (rid.isEmpty) return List.empty(); - List result = List.filled(id.length, null); - List pendingQuery = List.empty(growable: true); + List result = List.filled(rid.length, null); + List pendingQuery = List.empty(growable: true); if (!noCache) { - for (var idx = 0; idx < id.length; idx++) { - if (_cachedResponses.containsKey(id[idx])) { - result[idx] = _cachedResponses[id[idx]]; + for (var idx = 0; idx < rid.length; idx++) { + if (_cachedResponses.containsKey(rid[idx])) { + result[idx] = _cachedResponses[rid[idx]]; } else { - pendingQuery.add(id[idx]); + pendingQuery.add(rid[idx]); } } } @@ -52,12 +52,12 @@ class AttachmentProvider extends GetConnect { rawOut.data!.map((x) => Attachment.fromJson(x)).toList(); for (final item in out) { if (item.destination != 0 && item.isAnalyzed) { - _cachedResponses[item.id] = item; + _cachedResponses[item.rid] = item; } } for (var i = 0; i < out.length; i++) { - for (var j = 0; j < id.length; j++) { - if (out[i].id == id[j]) { + for (var j = 0; j < rid.length; j++) { + if (out[i].rid == rid[j]) { result[j] = out[i]; } } @@ -66,16 +66,16 @@ class AttachmentProvider extends GetConnect { return result; } - Future getMetadata(int id, {noCache = false}) async { - if (!noCache && _cachedResponses.containsKey(id)) { - return _cachedResponses[id]!; + Future getMetadata(String rid, {noCache = false}) async { + if (!noCache && _cachedResponses.containsKey(rid)) { + return _cachedResponses[rid]!; } - final resp = await get('/attachments/$id/meta'); + final resp = await get('/attachments/$rid/meta'); if (resp.statusCode == 200) { final result = Attachment.fromJson(resp.body); if (result.destination != 0 && result.isAnalyzed) { - _cachedResponses[id] = result; + _cachedResponses[rid] = result; } return result; } @@ -84,7 +84,7 @@ class AttachmentProvider extends GetConnect { } Future createAttachment( - Uint8List data, String path, String usage, Map? metadata, + Uint8List data, String path, String pool, Map? metadata, {Function(double)? onProgress}) async { final AuthProvider auth = Get.find(); if (auth.isAuthorized.isFalse) throw Exception('unauthorized'); @@ -108,7 +108,7 @@ class AttachmentProvider extends GetConnect { final payload = dio.FormData.fromMap({ 'alt': fileAlt, 'file': filePayload, - 'usage': usage, + 'pool': pool, if (mimetypeOverride != null) 'mimetype': mimetypeOverride, 'metadata': jsonEncode(metadata), }); @@ -133,8 +133,7 @@ class AttachmentProvider extends GetConnect { Future updateAttachment( int id, - String alt, - String usage, { + String alt, { bool isMature = false, }) async { final AuthProvider auth = Get.find(); @@ -144,7 +143,6 @@ class AttachmentProvider extends GetConnect { var resp = await client.put('/attachments/$id', { 'alt': alt, - 'usage': usage, 'is_mature': isMature, }); diff --git a/lib/screens/account/personalize.dart b/lib/screens/account/personalize.dart index 22a726d..34418ad 100644 --- a/lib/screens/account/personalize.dart +++ b/lib/screens/account/personalize.dart @@ -116,7 +116,7 @@ class _PersonalizeScreenState extends State { attachResult = await provider.createAttachment( await file.readAsBytes(), file.path, - 'p.$position', + 'avatar', null, ); } catch (e) { diff --git a/lib/screens/posts/post_editor.dart b/lib/screens/posts/post_editor.dart index 9255d29..aab71b2 100644 --- a/lib/screens/posts/post_editor.dart +++ b/lib/screens/posts/post_editor.dart @@ -65,7 +65,7 @@ class _PostPublishScreenState extends State { final AttachmentUploaderController uploader = Get.find(); if (uploader.queueOfUpload.any( - ((x) => x.usage == 'i.attachment' && x.isUploading), + ((x) => x.isUploading), )) { context.showErrorDialog('attachmentUploadInProgress'.tr); return; @@ -90,8 +90,8 @@ class _PostPublishScreenState extends State { if (resp.statusCode != 200) { context.showErrorDialog(resp.bodyString); } else { - _editorController.localClear(); _editorController.currentClear(); + _editorController.localClear(); AppRouter.instance.pop(resp.body); } diff --git a/lib/widgets/account/account_avatar.dart b/lib/widgets/account/account_avatar.dart index ca7b249..be19358 100644 --- a/lib/widgets/account/account_avatar.dart +++ b/lib/widgets/account/account_avatar.dart @@ -24,7 +24,6 @@ class AccountAvatar extends StatelessWidget { if (content is String) { direct = content.startsWith('http'); if (!isEmpty) isEmpty = content.isEmpty; - if (!isEmpty) isEmpty = content.endsWith('/attachments/0'); } final url = direct diff --git a/lib/widgets/attachments/attachment_attr_editor.dart b/lib/widgets/attachments/attachment_attr_editor.dart index 2a38b15..f067a8d 100644 --- a/lib/widgets/attachments/attachment_attr_editor.dart +++ b/lib/widgets/attachments/attachment_attr_editor.dart @@ -16,10 +16,12 @@ class AttachmentAttrEditorDialog extends StatefulWidget { }); @override - State createState() => _AttachmentAttrEditorDialogState(); + State createState() => + _AttachmentAttrEditorDialogState(); } -class _AttachmentAttrEditorDialogState extends State { +class _AttachmentAttrEditorDialogState + extends State { final _altController = TextEditingController(); bool _isBusy = false; @@ -33,7 +35,6 @@ class _AttachmentAttrEditorDialogState extends State final resp = await provider.updateAttachment( widget.item.id, _altController.value.text, - widget.item.usage, isMature: _isMature, ); @@ -109,7 +110,7 @@ class _AttachmentAttrEditorDialogState extends State TextButton( style: TextButton.styleFrom( foregroundColor: - Theme.of(context).colorScheme.onSurfaceVariant), + Theme.of(context).colorScheme.onSurfaceVariant), onPressed: () => Navigator.pop(context), child: Text('cancel'.tr), ), diff --git a/lib/widgets/attachments/attachment_editor.dart b/lib/widgets/attachments/attachment_editor.dart index 2ef9ab9..82607ef 100644 --- a/lib/widgets/attachments/attachment_editor.dart +++ b/lib/widgets/attachments/attachment_editor.dart @@ -22,19 +22,19 @@ import 'package:solian/widgets/attachments/attachment_attr_editor.dart'; import 'package:solian/widgets/attachments/attachment_fullscreen.dart'; class AttachmentEditorPopup extends StatefulWidget { - final String usage; + final String pool; final bool singleMode; final bool imageOnly; final bool autoUpload; final double? imageMaxWidth; final double? imageMaxHeight; - final List? initialAttachments; - final void Function(int) onAdd; - final void Function(int) onRemove; + final List? initialAttachments; + final void Function(String) onAdd; + final void Function(String) onRemove; const AttachmentEditorPopup({ super.key, - required this.usage, + required this.pool, required this.onAdd, required this.onRemove, this.singleMode = false, @@ -73,7 +73,7 @@ class _AttachmentEditorPopupState extends State { _enqueueTaskBatch(medias.map((x) { final file = File(x.path); - return AttachmentUploadTask(file: file, usage: widget.usage); + return AttachmentUploadTask(file: file, usage: widget.pool); })); } else { final media = await _imagePicker.pickMedia( @@ -83,7 +83,7 @@ class _AttachmentEditorPopupState extends State { if (media == null) return; _enqueueTask( - AttachmentUploadTask(file: File(media.path), usage: widget.usage), + AttachmentUploadTask(file: File(media.path), usage: widget.pool), ); } } @@ -97,7 +97,7 @@ class _AttachmentEditorPopupState extends State { final file = File(media.path); _enqueueTask( - AttachmentUploadTask(file: file, usage: widget.usage), + AttachmentUploadTask(file: file, usage: widget.pool), ); } @@ -113,7 +113,7 @@ class _AttachmentEditorPopupState extends State { List files = result.paths.map((path) => File(path!)).toList(); _enqueueTaskBatch(files.map((x) { - return AttachmentUploadTask(file: x, usage: widget.usage); + return AttachmentUploadTask(file: x, usage: widget.pool); })); } @@ -131,7 +131,7 @@ class _AttachmentEditorPopupState extends State { final file = File(media.path); _enqueueTask( - AttachmentUploadTask(file: file, usage: widget.usage), + AttachmentUploadTask(file: file, usage: widget.pool), ); } @@ -181,13 +181,11 @@ class _AttachmentEditorPopupState extends State { WidgetsBinding.instance.addPostFrameCallback((_) => controller.dispose()); if (input == null || input.isEmpty) return; - final value = int.tryParse(input); - if (value == null) return; final AttachmentProvider attach = Get.find(); - final result = await attach.getMetadata(value); + final result = await attach.getMetadata(input); if (result != null) { - widget.onAdd(result.id); + widget.onAdd(result.rid); setState(() => _attachments.add(result)); if (widget.singleMode) Navigator.pop(context); } @@ -202,11 +200,11 @@ class _AttachmentEditorPopupState extends State { _uploadController.uploadAttachmentWithCallback( data, 'Pasted Image', - widget.usage, + widget.pool, null, (item) { if (item == null) return; - widget.onAdd(item.id); + widget.onAdd(item.rid); if (mounted) { setState(() => _attachments.add(item)); if (widget.singleMode) Navigator.pop(context); @@ -413,11 +411,11 @@ class _AttachmentEditorPopupState extends State { : () { _uploadController .performSingleTask(index) - .then((r) { - if (r == null) return; - widget.onAdd(r.id); + .then((out) { + if (out == null) return; + widget.onAdd(out.rid); if (mounted) { - setState(() => _attachments.add(r)); + setState(() => _attachments.add(out)); if (widget.singleMode) { Navigator.pop(context); } @@ -515,7 +513,7 @@ class _AttachmentEditorPopupState extends State { ), onTap: () { _deleteAttachment(element).then((_) { - widget.onRemove(element.id); + widget.onRemove(element.rid); setState(() => _attachments.removeAt(index)); }); }, @@ -529,7 +527,7 @@ class _AttachmentEditorPopupState extends State { ), ), onTap: () { - widget.onRemove(element.id); + widget.onRemove(element.rid); setState(() => _attachments.removeAt(index)); }, ), @@ -560,7 +558,7 @@ class _AttachmentEditorPopupState extends State { void _startUploading() { _uploadController.performUploadQueue(onData: (r) { - widget.onAdd(r.id); + widget.onAdd(r.rid); if (mounted) { setState(() => _attachments.add(r)); if (widget.singleMode) Navigator.pop(context); @@ -584,7 +582,7 @@ class _AttachmentEditorPopupState extends State { if (_uploadController.isUploading.value) return; _enqueueTaskBatch(detail.files.map((x) { final file = File(x.path); - return AttachmentUploadTask(file: file, usage: widget.usage); + return AttachmentUploadTask(file: file, usage: widget.pool); })); }, child: Column( diff --git a/lib/widgets/attachments/attachment_fullscreen.dart b/lib/widgets/attachments/attachment_fullscreen.dart index cb5015b..80a12ef 100644 --- a/lib/widgets/attachments/attachment_fullscreen.dart +++ b/lib/widgets/attachments/attachment_fullscreen.dart @@ -67,9 +67,10 @@ class _AttachmentFullScreenState extends State { Future _saveToAlbum() async { final url = ServiceFinder.buildUrl( 'files', - '/attachments/${widget.item.id}', + '/attachments/${widget.item.rid}', ); + print(url); if (PlatformInfo.isWeb || PlatformInfo.isDesktop) { await launchUrlString(url); return; @@ -258,7 +259,7 @@ class _AttachmentFullScreenState extends State { spacing: 6, children: [ Text( - '#${widget.item.id}', + '#${widget.item.rid}', style: metaTextStyle, ), if (widget.item.metadata?['width'] != null && diff --git a/lib/widgets/attachments/attachment_item.dart b/lib/widgets/attachments/attachment_item.dart index 0b025b6..32e15cb 100644 --- a/lib/widgets/attachments/attachment_item.dart +++ b/lib/widgets/attachments/attachment_item.dart @@ -91,7 +91,7 @@ class _AttachmentItemState extends State { launchUrlString( ServiceFinder.buildUrl( 'files', - '/attachments/${widget.item.id}', + '/attachments/${widget.item.rid}', ), ); }, @@ -135,7 +135,7 @@ class _AttachmentItemImage extends StatelessWidget { fit: fit, imageUrl: ServiceFinder.buildUrl( 'files', - '/attachments/${item.id}', + '/attachments/${item.rid}', ), progressIndicatorBuilder: (context, url, downloadProgress) { return Center( @@ -240,7 +240,7 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> { final ratio = widget.item.metadata?['ratio'] ?? 16 / 9; _playerController = VideoPlayerController.networkUrl( Uri.parse( - ServiceFinder.buildUrl('files', '/attachments/${widget.item.id}'), + ServiceFinder.buildUrl('files', '/attachments/${widget.item.rid}'), ), ); _playerController!.initialize(); diff --git a/lib/widgets/attachments/attachment_list.dart b/lib/widgets/attachments/attachment_list.dart index 4d7d0c9..8bf6f04 100644 --- a/lib/widgets/attachments/attachment_list.dart +++ b/lib/widgets/attachments/attachment_list.dart @@ -14,7 +14,7 @@ import 'package:solian/widgets/sized_container.dart'; class AttachmentList extends StatefulWidget { final String parentId; - final List attachmentsId; + final List attachmentsId; final bool isGrid; final bool isForceGrid; final bool autoload; @@ -334,13 +334,13 @@ class AttachmentListEntry extends StatelessWidget { } class AttachmentSelfContainedEntry extends StatefulWidget { - final int id; + final String rid; final String parentId; final bool isDense; const AttachmentSelfContainedEntry({ super.key, - required this.id, + required this.rid, required this.parentId, this.isDense = false, }); @@ -359,10 +359,12 @@ class _AttachmentSelfContainedEntryState final AttachmentProvider attachments = Get.find(); return FutureBuilder( - future: attachments.getMetadata(widget.id), + future: attachments.getMetadata(widget.rid), builder: (context, snapshot) { if (!snapshot.hasData) { - return const Text('Loading...'); + return const Center( + child: CircularProgressIndicator(), + ); } return AttachmentListEntry( diff --git a/lib/widgets/chat/chat_event.dart b/lib/widgets/chat/chat_event.dart index 75f26e5..fe06956 100644 --- a/lib/widgets/chat/chat_event.dart +++ b/lib/widgets/chat/chat_event.dart @@ -39,8 +39,8 @@ class ChatEvent extends StatelessWidget { Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) { final attachments = item.body['attachments'] != null - ? List.from(item.body['attachments'].map((x) => x)) - : List.empty(); + ? List.from(item.body['attachments'].map((x) => x)) + : List.empty(); if (attachments.isEmpty) return const SizedBox(); diff --git a/lib/widgets/chat/chat_message_input.dart b/lib/widgets/chat/chat_message_input.dart index 339fc88..94ac8d2 100644 --- a/lib/widgets/chat/chat_message_input.dart +++ b/lib/widgets/chat/chat_message_input.dart @@ -59,7 +59,7 @@ class _ChatMessageInputState extends State { final TextEditingController _textController = TextEditingController(); final FocusNode _focusNode = FocusNode(); - final List _attachments = List.empty(growable: true); + final List _attachments = List.empty(growable: true); Event? _editTo; Event? _replyTo; @@ -68,7 +68,7 @@ class _ChatMessageInputState extends State { showModalBottomSheet( context: context, builder: (context) => AttachmentEditorPopup( - usage: 'm.attachment', + pool: 'messaging', initialAttachments: _attachments, onAdd: (value) { setState(() { @@ -103,7 +103,7 @@ class _ChatMessageInputState extends State { final AttachmentUploaderController uploader = Get.find(); if (uploader.queueOfUpload.any( - ((x) => x.usage == 'm.attachment' && x.isUploading), + ((x) => x.isUploading), )) { context.showErrorDialog('attachmentUploadInProgress'.tr); return; diff --git a/lib/widgets/markdown_text_content.dart b/lib/widgets/markdown_text_content.dart index f7de26e..5057eaf 100644 --- a/lib/widgets/markdown_text_content.dart +++ b/lib/widgets/markdown_text_content.dart @@ -131,7 +131,7 @@ class MarkdownTextContent extends StatelessWidget { child: AttachmentSelfContainedEntry( isDense: true, parentId: parentId, - id: int.parse(segments[1]), + rid: segments[1], ), ), ).paddingSymmetric(vertical: 4); diff --git a/lib/widgets/posts/editor/post_editor_thumbnail.dart b/lib/widgets/posts/editor/post_editor_thumbnail.dart index 34ad3a6..c133221 100644 --- a/lib/widgets/posts/editor/post_editor_thumbnail.dart +++ b/lib/widgets/posts/editor/post_editor_thumbnail.dart @@ -20,7 +20,7 @@ class _PostEditorThumbnailDialogState extends State { showModalBottomSheet( context: context, builder: (context) => AttachmentEditorPopup( - usage: 'i.attachment', + pool: 'interactive', singleMode: true, imageOnly: true, autoUpload: true, @@ -84,8 +84,7 @@ class _PostEditorThumbnailDialogState extends State { actions: [ TextButton( onPressed: () { - widget.controller.thumbnail.value = - int.tryParse(_attachmentController.text); + widget.controller.thumbnail.value = _attachmentController.text; Navigator.pop(context); }, child: Text('confirm'.tr), diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index 466e40d..f67b9a4 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -87,7 +87,7 @@ class _PostItemState extends State { child: AspectRatio( aspectRatio: 16 / 9, child: AttachmentSelfContainedEntry( - id: widget.item.body['thumbnail'], + rid: widget.item.body['thumbnail'], parentId: 'p${item.id}-thumbnail', ), ), @@ -292,8 +292,8 @@ class _PostItemState extends State { @override Widget build(BuildContext context) { - final List attachments = item.body['attachments'] is List - ? item.body['attachments']?.cast() + final List attachments = item.body['attachments'] is List + ? item.body['attachments']?.cast() : List.empty(); final hasAttachment = attachments.isNotEmpty; diff --git a/lib/widgets/stickers/sticker_uploader.dart b/lib/widgets/stickers/sticker_uploader.dart index 2305af7..7e6d897 100644 --- a/lib/widgets/stickers/sticker_uploader.dart +++ b/lib/widgets/stickers/sticker_uploader.dart @@ -29,7 +29,7 @@ class _StickerUploadDialogState extends State { showModalBottomSheet( context: context, builder: (context) => AttachmentEditorPopup( - usage: 'sticker', + pool: 'sticker', singleMode: true, imageOnly: true, autoUpload: true,