feat: update gallery count in profile when adding or removing galleries

Changed files
+8 -2
lib
+8 -2
lib/providers/profile_provider.dart
··· 176 176 final currentProfile = state.value; 177 177 if (currentProfile != null) { 178 178 final updatedGalleries = [newGallery, ...currentProfile.galleries]; 179 + final updatedProfile = currentProfile.profile.copyWith( 180 + galleryCount: (currentProfile.profile.galleryCount ?? 0) + 1, 181 + ); 179 182 state = AsyncValue.data( 180 - ProfileWithGalleries(profile: currentProfile.profile, galleries: updatedGalleries), 183 + ProfileWithGalleries(profile: updatedProfile, galleries: updatedGalleries), 181 184 ); 182 185 } 183 186 } ··· 186 189 final currentProfile = state.value; 187 190 if (currentProfile != null) { 188 191 final updatedGalleries = currentProfile.galleries.where((g) => g.uri != galleryUri).toList(); 192 + final updatedProfile = currentProfile.profile.copyWith( 193 + galleryCount: (currentProfile.profile.galleryCount ?? 1) - 1, 194 + ); 189 195 state = AsyncValue.data( 190 - ProfileWithGalleries(profile: currentProfile.profile, galleries: updatedGalleries), 196 + ProfileWithGalleries(profile: updatedProfile, galleries: updatedGalleries), 191 197 ); 192 198 } 193 199 }