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

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