🐛 Fix attachment set thumbnail

This commit is contained in:
LittleSheep 2024-12-28 18:16:59 +08:00
parent 2c7dc8c2ea
commit 1fca36293d
5 changed files with 34 additions and 9 deletions

View File

@ -233,19 +233,19 @@ class SnAttachmentProvider {
} }
Future<SnAttachment> updateOne( Future<SnAttachment> updateOne(
int id, { SnAttachment item, {
String? alt, String? alt,
int? thumbnailId, int? thumbnailId,
int? compressedId, int? compressedId,
Map<String, dynamic>? metadata, Map<String, dynamic>? metadata,
bool? isIndexable, bool? isIndexable,
}) async { }) async {
final resp = await _sn.client.put('/cgi/uc/attachments/$id', data: { final resp = await _sn.client.put('/cgi/uc/attachments/${item.id}', data: {
'alt': alt, 'alt': alt ?? item.alt,
'thumbnail': thumbnailId, 'thumbnail': thumbnailId ?? item.thumbnailId,
'compressed': compressedId, 'compressed': compressedId ?? item.compressedId,
'metadata': metadata, 'metadata': metadata ?? item.usermeta,
'is_indexable': isIndexable, 'is_indexable': isIndexable ?? item.isIndexable,
}); });
return SnAttachment.fromJson(resp.data); return SnAttachment.fromJson(resp.data);
} }

View File

@ -34,6 +34,7 @@ class SnAttachment with _$SnAttachment {
required DateTime? cleanedAt, required DateTime? cleanedAt,
required bool isAnalyzed, required bool isAnalyzed,
required bool isSelfRef, required bool isSelfRef,
required bool isIndexable,
required SnAttachment? ref, required SnAttachment? ref,
required int? refId, required int? refId,
required SnAttachmentPool? pool, required SnAttachmentPool? pool,

View File

@ -38,6 +38,7 @@ mixin _$SnAttachment {
DateTime? get cleanedAt => throw _privateConstructorUsedError; DateTime? get cleanedAt => throw _privateConstructorUsedError;
bool get isAnalyzed => throw _privateConstructorUsedError; bool get isAnalyzed => throw _privateConstructorUsedError;
bool get isSelfRef => throw _privateConstructorUsedError; bool get isSelfRef => throw _privateConstructorUsedError;
bool get isIndexable => throw _privateConstructorUsedError;
SnAttachment? get ref => throw _privateConstructorUsedError; SnAttachment? get ref => throw _privateConstructorUsedError;
int? get refId => throw _privateConstructorUsedError; int? get refId => throw _privateConstructorUsedError;
SnAttachmentPool? get pool => throw _privateConstructorUsedError; SnAttachmentPool? get pool => throw _privateConstructorUsedError;
@ -85,6 +86,7 @@ abstract class $SnAttachmentCopyWith<$Res> {
DateTime? cleanedAt, DateTime? cleanedAt,
bool isAnalyzed, bool isAnalyzed,
bool isSelfRef, bool isSelfRef,
bool isIndexable,
SnAttachment? ref, SnAttachment? ref,
int? refId, int? refId,
SnAttachmentPool? pool, SnAttachmentPool? pool,
@ -136,6 +138,7 @@ class _$SnAttachmentCopyWithImpl<$Res, $Val extends SnAttachment>
Object? cleanedAt = freezed, Object? cleanedAt = freezed,
Object? isAnalyzed = null, Object? isAnalyzed = null,
Object? isSelfRef = null, Object? isSelfRef = null,
Object? isIndexable = null,
Object? ref = freezed, Object? ref = freezed,
Object? refId = freezed, Object? refId = freezed,
Object? pool = freezed, Object? pool = freezed,
@ -221,6 +224,10 @@ class _$SnAttachmentCopyWithImpl<$Res, $Val extends SnAttachment>
? _value.isSelfRef ? _value.isSelfRef
: isSelfRef // ignore: cast_nullable_to_non_nullable : isSelfRef // ignore: cast_nullable_to_non_nullable
as bool, as bool,
isIndexable: null == isIndexable
? _value.isIndexable
: isIndexable // ignore: cast_nullable_to_non_nullable
as bool,
ref: freezed == ref ref: freezed == ref
? _value.ref ? _value.ref
: ref // ignore: cast_nullable_to_non_nullable : ref // ignore: cast_nullable_to_non_nullable
@ -352,6 +359,7 @@ abstract class _$$SnAttachmentImplCopyWith<$Res>
DateTime? cleanedAt, DateTime? cleanedAt,
bool isAnalyzed, bool isAnalyzed,
bool isSelfRef, bool isSelfRef,
bool isIndexable,
SnAttachment? ref, SnAttachment? ref,
int? refId, int? refId,
SnAttachmentPool? pool, SnAttachmentPool? pool,
@ -405,6 +413,7 @@ class __$$SnAttachmentImplCopyWithImpl<$Res>
Object? cleanedAt = freezed, Object? cleanedAt = freezed,
Object? isAnalyzed = null, Object? isAnalyzed = null,
Object? isSelfRef = null, Object? isSelfRef = null,
Object? isIndexable = null,
Object? ref = freezed, Object? ref = freezed,
Object? refId = freezed, Object? refId = freezed,
Object? pool = freezed, Object? pool = freezed,
@ -490,6 +499,10 @@ class __$$SnAttachmentImplCopyWithImpl<$Res>
? _value.isSelfRef ? _value.isSelfRef
: isSelfRef // ignore: cast_nullable_to_non_nullable : isSelfRef // ignore: cast_nullable_to_non_nullable
as bool, as bool,
isIndexable: null == isIndexable
? _value.isIndexable
: isIndexable // ignore: cast_nullable_to_non_nullable
as bool,
ref: freezed == ref ref: freezed == ref
? _value.ref ? _value.ref
: ref // ignore: cast_nullable_to_non_nullable : ref // ignore: cast_nullable_to_non_nullable
@ -560,6 +573,7 @@ class _$SnAttachmentImpl extends _SnAttachment {
required this.cleanedAt, required this.cleanedAt,
required this.isAnalyzed, required this.isAnalyzed,
required this.isSelfRef, required this.isSelfRef,
required this.isIndexable,
required this.ref, required this.ref,
required this.refId, required this.refId,
required this.pool, required this.pool,
@ -617,6 +631,8 @@ class _$SnAttachmentImpl extends _SnAttachment {
@override @override
final bool isSelfRef; final bool isSelfRef;
@override @override
final bool isIndexable;
@override
final SnAttachment? ref; final SnAttachment? ref;
@override @override
final int? refId; final int? refId;
@ -654,7 +670,7 @@ class _$SnAttachmentImpl extends _SnAttachment {
@override @override
String toString() { String toString() {
return 'SnAttachment(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, rid: $rid, uuid: $uuid, size: $size, name: $name, alt: $alt, mimetype: $mimetype, hash: $hash, destination: $destination, refCount: $refCount, contentRating: $contentRating, qualityRating: $qualityRating, cleanedAt: $cleanedAt, isAnalyzed: $isAnalyzed, isSelfRef: $isSelfRef, ref: $ref, refId: $refId, pool: $pool, poolId: $poolId, accountId: $accountId, thumbnailId: $thumbnailId, thumbnail: $thumbnail, compressedId: $compressedId, compressed: $compressed, usermeta: $usermeta, metadata: $metadata)'; return 'SnAttachment(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, rid: $rid, uuid: $uuid, size: $size, name: $name, alt: $alt, mimetype: $mimetype, hash: $hash, destination: $destination, refCount: $refCount, contentRating: $contentRating, qualityRating: $qualityRating, cleanedAt: $cleanedAt, isAnalyzed: $isAnalyzed, isSelfRef: $isSelfRef, isIndexable: $isIndexable, ref: $ref, refId: $refId, pool: $pool, poolId: $poolId, accountId: $accountId, thumbnailId: $thumbnailId, thumbnail: $thumbnail, compressedId: $compressedId, compressed: $compressed, usermeta: $usermeta, metadata: $metadata)';
} }
@override @override
@ -691,6 +707,8 @@ class _$SnAttachmentImpl extends _SnAttachment {
other.isAnalyzed == isAnalyzed) && other.isAnalyzed == isAnalyzed) &&
(identical(other.isSelfRef, isSelfRef) || (identical(other.isSelfRef, isSelfRef) ||
other.isSelfRef == isSelfRef) && other.isSelfRef == isSelfRef) &&
(identical(other.isIndexable, isIndexable) ||
other.isIndexable == isIndexable) &&
(identical(other.ref, ref) || other.ref == ref) && (identical(other.ref, ref) || other.ref == ref) &&
(identical(other.refId, refId) || other.refId == refId) && (identical(other.refId, refId) || other.refId == refId) &&
(identical(other.pool, pool) || other.pool == pool) && (identical(other.pool, pool) || other.pool == pool) &&
@ -731,6 +749,7 @@ class _$SnAttachmentImpl extends _SnAttachment {
cleanedAt, cleanedAt,
isAnalyzed, isAnalyzed,
isSelfRef, isSelfRef,
isIndexable,
ref, ref,
refId, refId,
pool, pool,
@ -780,6 +799,7 @@ abstract class _SnAttachment extends SnAttachment {
required final DateTime? cleanedAt, required final DateTime? cleanedAt,
required final bool isAnalyzed, required final bool isAnalyzed,
required final bool isSelfRef, required final bool isSelfRef,
required final bool isIndexable,
required final SnAttachment? ref, required final SnAttachment? ref,
required final int? refId, required final int? refId,
required final SnAttachmentPool? pool, required final SnAttachmentPool? pool,
@ -833,6 +853,8 @@ abstract class _SnAttachment extends SnAttachment {
@override @override
bool get isSelfRef; bool get isSelfRef;
@override @override
bool get isIndexable;
@override
SnAttachment? get ref; SnAttachment? get ref;
@override @override
int? get refId; int? get refId;

View File

@ -30,6 +30,7 @@ _$SnAttachmentImpl _$$SnAttachmentImplFromJson(Map<String, dynamic> json) =>
: DateTime.parse(json['cleaned_at'] as String), : DateTime.parse(json['cleaned_at'] as String),
isAnalyzed: json['is_analyzed'] as bool, isAnalyzed: json['is_analyzed'] as bool,
isSelfRef: json['is_self_ref'] as bool, isSelfRef: json['is_self_ref'] as bool,
isIndexable: json['is_indexable'] as bool,
ref: json['ref'] == null ref: json['ref'] == null
? null ? null
: SnAttachment.fromJson(json['ref'] as Map<String, dynamic>), : SnAttachment.fromJson(json['ref'] as Map<String, dynamic>),
@ -71,6 +72,7 @@ Map<String, dynamic> _$$SnAttachmentImplToJson(_$SnAttachmentImpl instance) =>
'cleaned_at': instance.cleanedAt?.toIso8601String(), 'cleaned_at': instance.cleanedAt?.toIso8601String(),
'is_analyzed': instance.isAnalyzed, 'is_analyzed': instance.isAnalyzed,
'is_self_ref': instance.isSelfRef, 'is_self_ref': instance.isSelfRef,
'is_indexable': instance.isIndexable,
'ref': instance.ref?.toJson(), 'ref': instance.ref?.toJson(),
'ref_id': instance.refId, 'ref_id': instance.refId,
'pool': instance.pool?.toJson(), 'pool': instance.pool?.toJson(),

View File

@ -99,7 +99,7 @@ class PostMediaPendingList extends StatelessWidget {
final attach = context.read<SnAttachmentProvider>(); final attach = context.read<SnAttachmentProvider>();
final newAttach = await attach.updateOne( final newAttach = await attach.updateOne(
attachments[idx].attachment!.id, attachments[idx].attachment!,
thumbnailId: thumbnail.id, thumbnailId: thumbnail.id,
); );