refactor: Refactor profile management. Remove profile cache provider, implement profile provider with async fetching and updating, and integrate profile editing functionality in the UI.
···1+// coverage:ignore-file
2+// GENERATED CODE - DO NOT MODIFY BY HAND
3+// ignore_for_file: type=lint
4+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
5+6+part of 'profile_with_galleries.dart';
7+8+// **************************************************************************
9+// FreezedGenerator
10+// **************************************************************************
11+12+T _$identity<T>(T value) => value;
13+14+final _privateConstructorUsedError = UnsupportedError(
15+ 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
16+);
17+18+ProfileWithGalleries _$ProfileWithGalleriesFromJson(Map<String, dynamic> json) {
19+ return _ProfileWithGalleries.fromJson(json);
20+}
21+22+/// @nodoc
23+mixin _$ProfileWithGalleries {
24+ Profile get profile => throw _privateConstructorUsedError;
25+ List<Gallery> get galleries => throw _privateConstructorUsedError;
26+27+ /// Serializes this ProfileWithGalleries to a JSON map.
28+ Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
29+30+ /// Create a copy of ProfileWithGalleries
31+ /// with the given fields replaced by the non-null parameter values.
32+ @JsonKey(includeFromJson: false, includeToJson: false)
33+ $ProfileWithGalleriesCopyWith<ProfileWithGalleries> get copyWith =>
34+ throw _privateConstructorUsedError;
35+}
36+37+/// @nodoc
38+abstract class $ProfileWithGalleriesCopyWith<$Res> {
39+ factory $ProfileWithGalleriesCopyWith(
40+ ProfileWithGalleries value,
41+ $Res Function(ProfileWithGalleries) then,
42+ ) = _$ProfileWithGalleriesCopyWithImpl<$Res, ProfileWithGalleries>;
43+ @useResult
44+ $Res call({Profile profile, List<Gallery> galleries});
45+46+ $ProfileCopyWith<$Res> get profile;
47+}
48+49+/// @nodoc
50+class _$ProfileWithGalleriesCopyWithImpl<
51+ $Res,
52+ $Val extends ProfileWithGalleries
53+>
54+ implements $ProfileWithGalleriesCopyWith<$Res> {
55+ _$ProfileWithGalleriesCopyWithImpl(this._value, this._then);
56+57+ // ignore: unused_field
58+ final $Val _value;
59+ // ignore: unused_field
60+ final $Res Function($Val) _then;
61+62+ /// Create a copy of ProfileWithGalleries
63+ /// with the given fields replaced by the non-null parameter values.
64+ @pragma('vm:prefer-inline')
65+ @override
66+ $Res call({Object? profile = null, Object? galleries = null}) {
67+ return _then(
68+ _value.copyWith(
69+ profile: null == profile
70+ ? _value.profile
71+ : profile // ignore: cast_nullable_to_non_nullable
72+ as Profile,
73+ galleries: null == galleries
74+ ? _value.galleries
75+ : galleries // ignore: cast_nullable_to_non_nullable
76+ as List<Gallery>,
77+ )
78+ as $Val,
79+ );
80+ }
81+82+ /// Create a copy of ProfileWithGalleries
83+ /// with the given fields replaced by the non-null parameter values.
84+ @override
85+ @pragma('vm:prefer-inline')
86+ $ProfileCopyWith<$Res> get profile {
87+ return $ProfileCopyWith<$Res>(_value.profile, (value) {
88+ return _then(_value.copyWith(profile: value) as $Val);
89+ });
90+ }
91+}
92+93+/// @nodoc
94+abstract class _$$ProfileWithGalleriesImplCopyWith<$Res>
95+ implements $ProfileWithGalleriesCopyWith<$Res> {
96+ factory _$$ProfileWithGalleriesImplCopyWith(
97+ _$ProfileWithGalleriesImpl value,
98+ $Res Function(_$ProfileWithGalleriesImpl) then,
99+ ) = __$$ProfileWithGalleriesImplCopyWithImpl<$Res>;
100+ @override
101+ @useResult
102+ $Res call({Profile profile, List<Gallery> galleries});
103+104+ @override
105+ $ProfileCopyWith<$Res> get profile;
106+}
107+108+/// @nodoc
109+class __$$ProfileWithGalleriesImplCopyWithImpl<$Res>
110+ extends _$ProfileWithGalleriesCopyWithImpl<$Res, _$ProfileWithGalleriesImpl>
111+ implements _$$ProfileWithGalleriesImplCopyWith<$Res> {
112+ __$$ProfileWithGalleriesImplCopyWithImpl(
113+ _$ProfileWithGalleriesImpl _value,
114+ $Res Function(_$ProfileWithGalleriesImpl) _then,
115+ ) : super(_value, _then);
116+117+ /// Create a copy of ProfileWithGalleries
118+ /// with the given fields replaced by the non-null parameter values.
119+ @pragma('vm:prefer-inline')
120+ @override
121+ $Res call({Object? profile = null, Object? galleries = null}) {
122+ return _then(
123+ _$ProfileWithGalleriesImpl(
124+ profile: null == profile
125+ ? _value.profile
126+ : profile // ignore: cast_nullable_to_non_nullable
127+ as Profile,
128+ galleries: null == galleries
129+ ? _value._galleries
130+ : galleries // ignore: cast_nullable_to_non_nullable
131+ as List<Gallery>,
132+ ),
133+ );
134+ }
135+}
136+137+/// @nodoc
138+@JsonSerializable()
139+class _$ProfileWithGalleriesImpl implements _ProfileWithGalleries {
140+ const _$ProfileWithGalleriesImpl({
141+ required this.profile,
142+ required final List<Gallery> galleries,
143+ }) : _galleries = galleries;
144+145+ factory _$ProfileWithGalleriesImpl.fromJson(Map<String, dynamic> json) =>
146+ _$$ProfileWithGalleriesImplFromJson(json);
147+148+ @override
149+ final Profile profile;
150+ final List<Gallery> _galleries;
151+ @override
152+ List<Gallery> get galleries {
153+ if (_galleries is EqualUnmodifiableListView) return _galleries;
154+ // ignore: implicit_dynamic_type
155+ return EqualUnmodifiableListView(_galleries);
156+ }
157+158+ @override
159+ String toString() {
160+ return 'ProfileWithGalleries(profile: $profile, galleries: $galleries)';
161+ }
162+163+ @override
164+ bool operator ==(Object other) {
165+ return identical(this, other) ||
166+ (other.runtimeType == runtimeType &&
167+ other is _$ProfileWithGalleriesImpl &&
168+ (identical(other.profile, profile) || other.profile == profile) &&
169+ const DeepCollectionEquality().equals(
170+ other._galleries,
171+ _galleries,
172+ ));
173+ }
174+175+ @JsonKey(includeFromJson: false, includeToJson: false)
176+ @override
177+ int get hashCode => Object.hash(
178+ runtimeType,
179+ profile,
180+ const DeepCollectionEquality().hash(_galleries),
181+ );
182+183+ /// Create a copy of ProfileWithGalleries
184+ /// with the given fields replaced by the non-null parameter values.
185+ @JsonKey(includeFromJson: false, includeToJson: false)
186+ @override
187+ @pragma('vm:prefer-inline')
188+ _$$ProfileWithGalleriesImplCopyWith<_$ProfileWithGalleriesImpl>
189+ get copyWith =>
190+ __$$ProfileWithGalleriesImplCopyWithImpl<_$ProfileWithGalleriesImpl>(
191+ this,
192+ _$identity,
193+ );
194+195+ @override
196+ Map<String, dynamic> toJson() {
197+ return _$$ProfileWithGalleriesImplToJson(this);
198+ }
199+}
200+201+abstract class _ProfileWithGalleries implements ProfileWithGalleries {
202+ const factory _ProfileWithGalleries({
203+ required final Profile profile,
204+ required final List<Gallery> galleries,
205+ }) = _$ProfileWithGalleriesImpl;
206+207+ factory _ProfileWithGalleries.fromJson(Map<String, dynamic> json) =
208+ _$ProfileWithGalleriesImpl.fromJson;
209+210+ @override
211+ Profile get profile;
212+ @override
213+ List<Gallery> get galleries;
214+215+ /// Create a copy of ProfileWithGalleries
216+ /// with the given fields replaced by the non-null parameter values.
217+ @override
218+ @JsonKey(includeFromJson: false, includeToJson: false)
219+ _$$ProfileWithGalleriesImplCopyWith<_$ProfileWithGalleriesImpl>
220+ get copyWith => throw _privateConstructorUsedError;
221+}
+23
lib/models/profile_with_galleries.g.dart
···00000000000000000000000
···1+// GENERATED CODE - DO NOT MODIFY BY HAND
2+3+part of 'profile_with_galleries.dart';
4+5+// **************************************************************************
6+// JsonSerializableGenerator
7+// **************************************************************************
8+9+_$ProfileWithGalleriesImpl _$$ProfileWithGalleriesImplFromJson(
10+ Map<String, dynamic> json,
11+) => _$ProfileWithGalleriesImpl(
12+ profile: Profile.fromJson(json['profile'] as Map<String, dynamic>),
13+ galleries: (json['galleries'] as List<dynamic>)
14+ .map((e) => Gallery.fromJson(e as Map<String, dynamic>))
15+ .toList(),
16+);
17+18+Map<String, dynamic> _$$ProfileWithGalleriesImplToJson(
19+ _$ProfileWithGalleriesImpl instance,
20+) => <String, dynamic>{
21+ 'profile': instance.profile,
22+ 'galleries': instance.galleries,
23+};
+5
lib/providers/gallery_cache_provider.dart
···2728 Gallery? getGallery(String uri) => state[uri];
290000030 Future<void> toggleFavorite(String uri) async {
31 // Fetch the latest gallery from the API to ensure up-to-date favorite state
32 final latestGallery = await apiService.getGallery(uri: uri);
···2728 Gallery? getGallery(String uri) => state[uri];
2930+ void setGalleriesForActor(String did, List<Gallery> galleries) {
31+ setGalleries(galleries);
32+ // Optionally, you could keep a mapping of actor DID to gallery URIs if needed
33+ }
34+35 Future<void> toggleFavorite(String uri) async {
36 // Fetch the latest gallery from the API to ensure up-to-date favorite state
37 final latestGallery = await apiService.getGallery(uri: uri);
+1-1
lib/providers/gallery_cache_provider.g.dart
···6// RiverpodGenerator
7// **************************************************************************
89-String _$galleryCacheHash() => r'dc64ef86246ea4ac742837cfcc8a9353375f2144';
1011/// Holds a cache of galleries by URI.
12///
···6// RiverpodGenerator
7// **************************************************************************
89+String _$galleryCacheHash() => r'24f705b282f56332ab62705a6b29eb3f3c80142b';
1011/// Holds a cache of galleries by URI.
12///