feat(mobile): add the number of activities to the activity button label

This commit is contained in:
idubnori
2025-12-18 01:31:29 +09:00
parent 3e8635431e
commit d63a1bcd07
12 changed files with 50 additions and 29 deletions
+9 -5
View File
@@ -26,11 +26,10 @@ class AlbumActivity extends _$AlbumActivity {
ref.read(albumActivityProvider(albumId).notifier)._removeFromState(id);
}
if (removedActivity.type == ActivityType.comment) {
ref.watch(activityStatisticsProvider(albumId, assetId).notifier).removeActivity();
if (assetId != null) {
ref.watch(activityStatisticsProvider(albumId).notifier).removeActivity();
}
// Update statistics for both comments and likes
ref.watch(activityStatisticsProvider(albumId, assetId).notifier).removeActivity();
if (assetId != null) {
ref.watch(activityStatisticsProvider(albumId).notifier).removeActivity();
}
}
}
@@ -42,6 +41,11 @@ class AlbumActivity extends _$AlbumActivity {
if (assetId != null) {
ref.read(albumActivityProvider(albumId).notifier)._addToState(activity.requireValue);
}
// Update statistics when adding a like
ref.watch(activityStatisticsProvider(albumId, assetId).notifier).addActivity();
if (assetId != null) {
ref.watch(activityStatisticsProvider(albumId).notifier).addActivity();
}
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ part of 'activity.provider.dart';
// RiverpodGenerator
// **************************************************************************
String _$albumActivityHash() => r'154e8ae98da3efc142369eae46d4005468fd67da';
String _$albumActivityHash() => r'fe472b87b56ce4e3802833799bf707779ccc02e3';
/// Copied from Dart SDK
class _SystemHash {
@@ -4,12 +4,12 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'activity_statistics.provider.g.dart';
// ignore: unintended_html_in_doc_comment
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
@riverpod
class ActivityStatistics extends _$ActivityStatistics {
@override
int build(String albumId, [String? assetId]) {
ref.watch(activityServiceProvider).getStatistics(albumId, assetId: assetId).then((stats) => state = stats.comments);
ref.watch(activityServiceProvider).getStatistics(albumId, assetId: assetId).then((stats) => state = stats.total);
return 0;
}
+7 -7
View File
@@ -7,7 +7,7 @@ part of 'activity_statistics.provider.dart';
// **************************************************************************
String _$activityStatisticsHash() =>
r'1f43f0bcb11c754ca3cb586a13570db25023b9a8';
r'ae0123a6ce129988e21f7327273af4d9acbae0f6';
/// Copied from Dart SDK
class _SystemHash {
@@ -37,22 +37,22 @@ abstract class _$ActivityStatistics extends BuildlessAutoDisposeNotifier<int> {
int build(String albumId, [String? assetId]);
}
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
///
/// Copied from [ActivityStatistics].
@ProviderFor(ActivityStatistics)
const activityStatisticsProvider = ActivityStatisticsFamily();
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
///
/// Copied from [ActivityStatistics].
class ActivityStatisticsFamily extends Family<int> {
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
///
/// Copied from [ActivityStatistics].
const ActivityStatisticsFamily();
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
///
/// Copied from [ActivityStatistics].
ActivityStatisticsProvider call(String albumId, [String? assetId]) {
@@ -81,12 +81,12 @@ class ActivityStatisticsFamily extends Family<int> {
String? get name => r'activityStatisticsProvider';
}
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
///
/// Copied from [ActivityStatistics].
class ActivityStatisticsProvider
extends AutoDisposeNotifierProviderImpl<ActivityStatistics, int> {
/// Maintains the current number of comments by <shared-album, asset>
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
///
/// Copied from [ActivityStatistics].
ActivityStatisticsProvider(String albumId, [String? assetId])