diff --git a/lib/providers/sn_attachment.dart b/lib/providers/sn_attachment.dart index aeb383f..4856bc3 100644 --- a/lib/providers/sn_attachment.dart +++ b/lib/providers/sn_attachment.dart @@ -233,19 +233,19 @@ class SnAttachmentProvider { } Future updateOne( - int id, { + SnAttachment item, { String? alt, int? thumbnailId, int? compressedId, Map? metadata, bool? isIndexable, }) async { - final resp = await _sn.client.put('/cgi/uc/attachments/$id', data: { - 'alt': alt, - 'thumbnail': thumbnailId, - 'compressed': compressedId, - 'metadata': metadata, - 'is_indexable': isIndexable, + final resp = await _sn.client.put('/cgi/uc/attachments/${item.id}', data: { + 'alt': alt ?? item.alt, + 'thumbnail': thumbnailId ?? item.thumbnailId, + 'compressed': compressedId ?? item.compressedId, + 'metadata': metadata ?? item.usermeta, + 'is_indexable': isIndexable ?? item.isIndexable, }); return SnAttachment.fromJson(resp.data); } diff --git a/lib/types/attachment.dart b/lib/types/attachment.dart index 40b25fc..1bf9948 100644 --- a/lib/types/attachment.dart +++ b/lib/types/attachment.dart @@ -34,6 +34,7 @@ class SnAttachment with _$SnAttachment { required DateTime? cleanedAt, required bool isAnalyzed, required bool isSelfRef, + required bool isIndexable, required SnAttachment? ref, required int? refId, required SnAttachmentPool? pool, diff --git a/lib/types/attachment.freezed.dart b/lib/types/attachment.freezed.dart index dcb763f..d50cf22 100644 --- a/lib/types/attachment.freezed.dart +++ b/lib/types/attachment.freezed.dart @@ -38,6 +38,7 @@ mixin _$SnAttachment { DateTime? get cleanedAt => throw _privateConstructorUsedError; bool get isAnalyzed => throw _privateConstructorUsedError; bool get isSelfRef => throw _privateConstructorUsedError; + bool get isIndexable => throw _privateConstructorUsedError; SnAttachment? get ref => throw _privateConstructorUsedError; int? get refId => throw _privateConstructorUsedError; SnAttachmentPool? get pool => throw _privateConstructorUsedError; @@ -85,6 +86,7 @@ abstract class $SnAttachmentCopyWith<$Res> { DateTime? cleanedAt, bool isAnalyzed, bool isSelfRef, + bool isIndexable, SnAttachment? ref, int? refId, SnAttachmentPool? pool, @@ -136,6 +138,7 @@ class _$SnAttachmentCopyWithImpl<$Res, $Val extends SnAttachment> Object? cleanedAt = freezed, Object? isAnalyzed = null, Object? isSelfRef = null, + Object? isIndexable = null, Object? ref = freezed, Object? refId = freezed, Object? pool = freezed, @@ -221,6 +224,10 @@ class _$SnAttachmentCopyWithImpl<$Res, $Val extends SnAttachment> ? _value.isSelfRef : isSelfRef // ignore: cast_nullable_to_non_nullable as bool, + isIndexable: null == isIndexable + ? _value.isIndexable + : isIndexable // ignore: cast_nullable_to_non_nullable + as bool, ref: freezed == ref ? _value.ref : ref // ignore: cast_nullable_to_non_nullable @@ -352,6 +359,7 @@ abstract class _$$SnAttachmentImplCopyWith<$Res> DateTime? cleanedAt, bool isAnalyzed, bool isSelfRef, + bool isIndexable, SnAttachment? ref, int? refId, SnAttachmentPool? pool, @@ -405,6 +413,7 @@ class __$$SnAttachmentImplCopyWithImpl<$Res> Object? cleanedAt = freezed, Object? isAnalyzed = null, Object? isSelfRef = null, + Object? isIndexable = null, Object? ref = freezed, Object? refId = freezed, Object? pool = freezed, @@ -490,6 +499,10 @@ class __$$SnAttachmentImplCopyWithImpl<$Res> ? _value.isSelfRef : isSelfRef // ignore: cast_nullable_to_non_nullable as bool, + isIndexable: null == isIndexable + ? _value.isIndexable + : isIndexable // ignore: cast_nullable_to_non_nullable + as bool, ref: freezed == ref ? _value.ref : ref // ignore: cast_nullable_to_non_nullable @@ -560,6 +573,7 @@ class _$SnAttachmentImpl extends _SnAttachment { required this.cleanedAt, required this.isAnalyzed, required this.isSelfRef, + required this.isIndexable, required this.ref, required this.refId, required this.pool, @@ -617,6 +631,8 @@ class _$SnAttachmentImpl extends _SnAttachment { @override final bool isSelfRef; @override + final bool isIndexable; + @override final SnAttachment? ref; @override final int? refId; @@ -654,7 +670,7 @@ class _$SnAttachmentImpl extends _SnAttachment { @override 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 @@ -691,6 +707,8 @@ class _$SnAttachmentImpl extends _SnAttachment { other.isAnalyzed == isAnalyzed) && (identical(other.isSelfRef, isSelfRef) || other.isSelfRef == isSelfRef) && + (identical(other.isIndexable, isIndexable) || + other.isIndexable == isIndexable) && (identical(other.ref, ref) || other.ref == ref) && (identical(other.refId, refId) || other.refId == refId) && (identical(other.pool, pool) || other.pool == pool) && @@ -731,6 +749,7 @@ class _$SnAttachmentImpl extends _SnAttachment { cleanedAt, isAnalyzed, isSelfRef, + isIndexable, ref, refId, pool, @@ -780,6 +799,7 @@ abstract class _SnAttachment extends SnAttachment { required final DateTime? cleanedAt, required final bool isAnalyzed, required final bool isSelfRef, + required final bool isIndexable, required final SnAttachment? ref, required final int? refId, required final SnAttachmentPool? pool, @@ -833,6 +853,8 @@ abstract class _SnAttachment extends SnAttachment { @override bool get isSelfRef; @override + bool get isIndexable; + @override SnAttachment? get ref; @override int? get refId; diff --git a/lib/types/attachment.g.dart b/lib/types/attachment.g.dart index 634dea8..e363506 100644 --- a/lib/types/attachment.g.dart +++ b/lib/types/attachment.g.dart @@ -30,6 +30,7 @@ _$SnAttachmentImpl _$$SnAttachmentImplFromJson(Map json) => : DateTime.parse(json['cleaned_at'] as String), isAnalyzed: json['is_analyzed'] as bool, isSelfRef: json['is_self_ref'] as bool, + isIndexable: json['is_indexable'] as bool, ref: json['ref'] == null ? null : SnAttachment.fromJson(json['ref'] as Map), @@ -71,6 +72,7 @@ Map _$$SnAttachmentImplToJson(_$SnAttachmentImpl instance) => 'cleaned_at': instance.cleanedAt?.toIso8601String(), 'is_analyzed': instance.isAnalyzed, 'is_self_ref': instance.isSelfRef, + 'is_indexable': instance.isIndexable, 'ref': instance.ref?.toJson(), 'ref_id': instance.refId, 'pool': instance.pool?.toJson(), diff --git a/lib/widgets/post/post_media_pending_list.dart b/lib/widgets/post/post_media_pending_list.dart index 5274a9d..a3ae432 100644 --- a/lib/widgets/post/post_media_pending_list.dart +++ b/lib/widgets/post/post_media_pending_list.dart @@ -99,7 +99,7 @@ class PostMediaPendingList extends StatelessWidget { final attach = context.read(); final newAttach = await attach.updateOne( - attachments[idx].attachment!.id, + attachments[idx].attachment!, thumbnailId: thumbnail.id, );