From 2c7dc8c2ea6afe56fb39982e8af39d1ab2f42e10 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 28 Dec 2024 17:37:58 +0800 Subject: [PATCH] :bug: Fix attachment uploading progress --- lib/providers/sn_attachment.dart | 13 +++++++++---- lib/widgets/post/post_media_pending_list.dart | 5 ++++- macos/Podfile.lock | 10 ++++++++-- pubspec.yaml | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/providers/sn_attachment.dart b/lib/providers/sn_attachment.dart index 162746f..aeb383f 100644 --- a/lib/providers/sn_attachment.dart +++ b/lib/providers/sn_attachment.dart @@ -198,13 +198,16 @@ class SnAttachmentProvider { data, place.rid, entry.key, + onProgress: (progress) { + final overallProgress = (currentTask + progress) / chunks.length; + onProgress?.call(overallProgress); + }, ); + currentTask++; final overallProgress = currentTask / chunks.length; onProgress?.call(overallProgress); - currentTask++; - if (result is SnAttachmentFragment) { place = result; } else { @@ -232,13 +235,15 @@ class SnAttachmentProvider { Future updateOne( int id, { String? alt, - String? thumbnail, + int? thumbnailId, + int? compressedId, Map? metadata, bool? isIndexable, }) async { final resp = await _sn.client.put('/cgi/uc/attachments/$id', data: { 'alt': alt, - 'thumbnail': thumbnail, + 'thumbnail': thumbnailId, + 'compressed': compressedId, 'metadata': metadata, 'is_indexable': isIndexable, }); diff --git a/lib/widgets/post/post_media_pending_list.dart b/lib/widgets/post/post_media_pending_list.dart index 8dd6d21..5274a9d 100644 --- a/lib/widgets/post/post_media_pending_list.dart +++ b/lib/widgets/post/post_media_pending_list.dart @@ -98,7 +98,10 @@ class PostMediaPendingList extends StatelessWidget { if (!context.mounted) return; final attach = context.read(); - final newAttach = await attach.updateOne(attachments[idx].attachment!.id, thumbnail: thumbnail.rid); + final newAttach = await attach.updateOne( + attachments[idx].attachment!.id, + thumbnailId: thumbnail.id, + ); onUpdate!(idx, PostWriteMedia(newAttach)); } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index de14a5e..bccd500 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -134,7 +134,7 @@ PODS: - GoogleUtilities/Privacy - in_app_review (2.0.0): - FlutterMacOS - - livekit_client (2.3.2): + - livekit_client (2.3.3): - flutter_webrtc - FlutterMacOS - WebRTC-SDK (= 125.6422.06) @@ -170,6 +170,8 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - video_compress (0.3.0): + - FlutterMacOS - wakelock_plus (0.0.1): - FlutterMacOS - WebRTC-SDK (125.6422.06) @@ -201,6 +203,7 @@ DEPENDENCIES: - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite_darwin (from `Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - video_compress (from `Flutter/ephemeral/.symlinks/plugins/video_compress/macos`) - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) SPEC REPOS: @@ -272,6 +275,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + video_compress: + :path: Flutter/ephemeral/.symlinks/plugins/video_compress/macos wakelock_plus: :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos @@ -299,7 +304,7 @@ SPEC CHECKSUMS: GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d in_app_review: a6a031b9acd03c7d103e341aa334adf2c493fb93 - livekit_client: 9fdcb22df3de55e6d4b24bdc3b5eb1c0269d774a + livekit_client: 8b1b90a6f2445d127a018ce93cc8cf6d8ab62982 media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82 media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5 media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5 @@ -314,6 +319,7 @@ SPEC CHECKSUMS: shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 + video_compress: c896234f100791b5fef7f049afa38f6d2ef7b42f wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 WebRTC-SDK: 79942c006ea64f6fb48d7da8a4786dfc820bc1db diff --git a/pubspec.yaml b/pubspec.yaml index bfe6dd2..489a1d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 2.1.1+39 +version: 2.2.1+40 environment: sdk: ^3.5.4