🐛 Fix attachment uploading progress

This commit is contained in:
LittleSheep 2024-12-28 17:37:58 +08:00
parent cf0df91d8c
commit 2c7dc8c2ea
4 changed files with 22 additions and 8 deletions

View File

@ -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<SnAttachment> updateOne(
int id, {
String? alt,
String? thumbnail,
int? thumbnailId,
int? compressedId,
Map<String, dynamic>? 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,
});

View File

@ -98,7 +98,10 @@ class PostMediaPendingList extends StatelessWidget {
if (!context.mounted) return;
final attach = context.read<SnAttachmentProvider>();
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));
}

View File

@ -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

View File

@ -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