From e503c3f02f51ea6f6c03743aa2b18154f435a4b7 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 29 Dec 2024 11:09:54 +0800 Subject: [PATCH] :zap: Use analyze now for images --- lib/controllers/post_write_controller.dart | 1 + lib/providers/sn_attachment.dart | 4 ++++ lib/widgets/chat/chat_message_input.dart | 1 + 3 files changed, 6 insertions(+) diff --git a/lib/controllers/post_write_controller.dart b/lib/controllers/post_write_controller.dart index 98ceaaf..f3b5569 100644 --- a/lib/controllers/post_write_controller.dart +++ b/lib/controllers/post_write_controller.dart @@ -247,6 +247,7 @@ class PostWriteController extends ChangeNotifier { media.toFile()!, place.$1, place.$2, + analyzeNow: media.type == SnMediaType.image, onProgress: (value) { progress = value; notifyListeners(); diff --git a/lib/providers/sn_attachment.dart b/lib/providers/sn_attachment.dart index ce7da94..7a0dbb5 100644 --- a/lib/providers/sn_attachment.dart +++ b/lib/providers/sn_attachment.dart @@ -154,10 +154,12 @@ class SnAttachmentProvider { String rid, String cid, { Function(double progress)? onProgress, + bool analyzeNow = false, }) async { final resp = await _sn.client.post( '/cgi/uc/fragments/$rid/$cid', data: data, + queryParameters: {'analyzeNow': analyzeNow}, options: Options(headers: {'Content-Type': 'application/octet-stream'}), onSendProgress: (count, total) { if (onProgress != null) { @@ -178,6 +180,7 @@ class SnAttachmentProvider { SnAttachmentFragment place, int chunkSize, { Function(double progress)? onProgress, + bool analyzeNow = false, }) async { final Map chunks = place.fileChunks; var completedTasks = 0; @@ -200,6 +203,7 @@ class SnAttachmentProvider { data, place.rid, entry.key, + analyzeNow: analyzeNow, onProgress: (progress) { final overallProgress = (completedTasks + progress) / chunks.length; onProgress?.call(overallProgress); diff --git a/lib/widgets/chat/chat_message_input.dart b/lib/widgets/chat/chat_message_input.dart index 460b827..697ca31 100644 --- a/lib/widgets/chat/chat_message_input.dart +++ b/lib/widgets/chat/chat_message_input.dart @@ -83,6 +83,7 @@ class ChatMessageInputState extends State { media.toFile()!, place.$1, place.$2, + analyzeNow: media.type == SnMediaType.image, onProgress: (progress) { // Calculate overall progress for attachments setState(() {