Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Refresh social overlay after sync

ashil-pilote34bd1b8456f
diff --git a/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart b/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart
index c9c0a7ca33..b1a6343804 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/file_social_overlay.dart
@@ -7,6 +7,8 @@ import "package:ente_strings/ente_strings.dart";
import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
import "package:logging/logging.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/social_data_updated_event.dart";
import "package:photos/models/api/collection/user.dart";
import "package:photos/models/collection/collection.dart";
import "package:photos/models/file/file.dart";
@@ -70,6 +72,9 @@ class FileSocialOverlay extends StatefulWidget {
}
class _FileSocialOverlayState extends State<FileSocialOverlay> {
+ late final StreamSubscription<SocialDataUpdatedEvent>
+ _socialDataUpdatedSubscription;
+
bool _hasEligibleSharedCollections = false;
bool _hasLiked = false;
int _commentCount = 0;
@@ -82,6 +87,9 @@ class _FileSocialOverlayState extends State<FileSocialOverlay> {
@override
void initState() {
super.initState();
+ _socialDataUpdatedSubscription = Bus.instance
+ .on<SocialDataUpdatedEvent>()
+ .listen((_) => unawaited(_refreshSocialState()));
unawaited(_refreshSocialState());
}
@@ -93,6 +101,12 @@ class _FileSocialOverlayState extends State<FileSocialOverlay> {
}
}
+ @override
+ void dispose() {
+ _socialDataUpdatedSubscription.cancel();
+ super.dispose();
+ }
+
void _clearSocialState() {
_loadedFileID = null;
_hasEligibleSharedCollections = false;