Use analyze now for images

This commit is contained in:
LittleSheep 2024-12-29 11:09:54 +08:00
parent d4fbdd397e
commit e503c3f02f
3 changed files with 6 additions and 0 deletions

View File

@ -247,6 +247,7 @@ class PostWriteController extends ChangeNotifier {
media.toFile()!, media.toFile()!,
place.$1, place.$1,
place.$2, place.$2,
analyzeNow: media.type == SnMediaType.image,
onProgress: (value) { onProgress: (value) {
progress = value; progress = value;
notifyListeners(); notifyListeners();

View File

@ -154,10 +154,12 @@ class SnAttachmentProvider {
String rid, String rid,
String cid, { String cid, {
Function(double progress)? onProgress, Function(double progress)? onProgress,
bool analyzeNow = false,
}) async { }) async {
final resp = await _sn.client.post( final resp = await _sn.client.post(
'/cgi/uc/fragments/$rid/$cid', '/cgi/uc/fragments/$rid/$cid',
data: data, data: data,
queryParameters: {'analyzeNow': analyzeNow},
options: Options(headers: {'Content-Type': 'application/octet-stream'}), options: Options(headers: {'Content-Type': 'application/octet-stream'}),
onSendProgress: (count, total) { onSendProgress: (count, total) {
if (onProgress != null) { if (onProgress != null) {
@ -178,6 +180,7 @@ class SnAttachmentProvider {
SnAttachmentFragment place, SnAttachmentFragment place,
int chunkSize, { int chunkSize, {
Function(double progress)? onProgress, Function(double progress)? onProgress,
bool analyzeNow = false,
}) async { }) async {
final Map<String, dynamic> chunks = place.fileChunks; final Map<String, dynamic> chunks = place.fileChunks;
var completedTasks = 0; var completedTasks = 0;
@ -200,6 +203,7 @@ class SnAttachmentProvider {
data, data,
place.rid, place.rid,
entry.key, entry.key,
analyzeNow: analyzeNow,
onProgress: (progress) { onProgress: (progress) {
final overallProgress = (completedTasks + progress) / chunks.length; final overallProgress = (completedTasks + progress) / chunks.length;
onProgress?.call(overallProgress); onProgress?.call(overallProgress);

View File

@ -83,6 +83,7 @@ class ChatMessageInputState extends State<ChatMessageInput> {
media.toFile()!, media.toFile()!,
place.$1, place.$1,
place.$2, place.$2,
analyzeNow: media.type == SnMediaType.image,
onProgress: (progress) { onProgress: (progress) {
// Calculate overall progress for attachments // Calculate overall progress for attachments
setState(() { setState(() {