Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove moments and disable memories debug by default

laurenspriemfa6694e2f944
diff --git a/mobile/apps/photos/lib/models/search/search_types.dart b/mobile/apps/photos/lib/models/search/search_types.dart
index 3485429bc2..e0df25fe2c 100644
--- a/mobile/apps/photos/lib/models/search/search_types.dart
+++ b/mobile/apps/photos/lib/models/search/search_types.dart
@@ -44,8 +44,10 @@ enum SectionType {
face,
magic,
location,
- // includes year, month , day, event ResultType
- moment,
+
+ /// WARNING: Not for production purposes, only kept for debugging memories
+ memoriesDebug,
+
album,
// People section shows the files shared by other persons
contacts,
@@ -60,8 +62,8 @@ extension SectionTypeExtensions on SectionType {
return S.of(context).people;
case SectionType.magic:
return S.of(context).discover;
- case SectionType.moment:
- return S.of(context).moments;
+ case SectionType.memoriesDebug:
+ return "Debug memories (internal)";
case SectionType.location:
return S.of(context).locations;
case SectionType.contacts:
@@ -79,8 +81,8 @@ extension SectionTypeExtensions on SectionType {
return S.of(context).searchPersonsEmptySection;
case SectionType.magic:
return S.of(context).searchDiscoverEmptySection;
- case SectionType.moment:
- return S.of(context).searchDatesEmptySection;
+ case SectionType.memoriesDebug:
+ return "For debugging for internal users only";
case SectionType.location:
return S.of(context).searchLocationEmptySection;
case SectionType.contacts:
@@ -98,7 +100,7 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
case SectionType.magic:
- case SectionType.moment:
+ case SectionType.memoriesDebug:
case SectionType.fileTypesAndExtension:
return false;
case SectionType.location:
@@ -111,14 +113,14 @@ extension SectionTypeExtensions on SectionType {
bool get sortByName =>
this != SectionType.face &&
this != SectionType.magic &&
- this != SectionType.moment &&
+ this != SectionType.memoriesDebug &&
this != SectionType.contacts;
bool get isEmptyCTAVisible {
switch (this) {
case SectionType.face:
case SectionType.magic:
- case SectionType.moment:
+ case SectionType.memoriesDebug:
case SectionType.fileTypesAndExtension:
return false;
case SectionType.location:
@@ -136,8 +138,8 @@ extension SectionTypeExtensions on SectionType {
case SectionType.magic:
// todo: later
return "temp";
- case SectionType.moment:
- return S.of(context).addNew;
+ case SectionType.memoriesDebug:
+ return "Test memories";
case SectionType.location:
return S.of(context).addNew;
case SectionType.contacts:
@@ -155,7 +157,7 @@ extension SectionTypeExtensions on SectionType {
return Icons.adaptive.arrow_forward_outlined;
case SectionType.magic:
return null;
- case SectionType.moment:
+ case SectionType.memoriesDebug:
return null;
case SectionType.location:
return Icons.add_location_alt_outlined;
@@ -234,13 +236,11 @@ extension SectionTypeExtensions on SectionType {
return SearchService.instance.getAllFace(limit);
case SectionType.magic:
return SearchService.instance.getMagicSectionResults(context!);
-
- case SectionType.moment:
- if (flagService.internalUser) {
+ case SectionType.memoriesDebug:
+ if (flagService.internalUser && localSettings.isDebugMemoriesEnabled) {
return SearchService.instance.smartMemories(context!, limit);
}
- return SearchService.instance.getRandomMomentsSearchResults(context!);
-
+ return Future.value([]);
case SectionType.location:
return SearchService.instance.getAllLocationTags(limit);
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/moments_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/moments_section.dart
index 8ac738d70e..85496fbc90 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/moments_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/moments_section.dart
@@ -33,11 +33,11 @@ class _MomentsSectionState extends State<MomentsSection> {
super.initState();
_momentsSearchResults = widget.momentsSearchResults;
- final streamsToListenTo = SectionType.moment.sectionUpdateEvents();
+ final streamsToListenTo = SectionType.memoriesDebug.sectionUpdateEvents();
for (Stream<Event> stream in streamsToListenTo) {
streamSubscriptions.add(
stream.listen((event) async {
- _momentsSearchResults = (await SectionType.moment.getData(
+ _momentsSearchResults = (await SectionType.memoriesDebug.getData(
context,
limit: kSearchSectionLimit,
)) as List<GenericSearchResult>;
@@ -74,14 +74,14 @@ class _MomentsSectionState extends State<MomentsSection> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- SectionType.moment.sectionTitle(context),
+ SectionType.memoriesDebug.sectionTitle(context),
style: textTheme.largeBold,
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 4),
child: Text(
- SectionType.moment.getEmptyStateText(context),
+ SectionType.memoriesDebug.getEmptyStateText(context),
style: textTheme.smallMuted,
),
),
@@ -89,7 +89,7 @@ class _MomentsSectionState extends State<MomentsSection> {
),
),
const SizedBox(width: 8),
- const SearchSectionEmptyCTAIcon(SectionType.moment),
+ const SearchSectionEmptyCTAIcon(SectionType.memoriesDebug),
],
),
);
@@ -100,7 +100,7 @@ class _MomentsSectionState extends State<MomentsSection> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SectionHeader(
- SectionType.moment,
+ SectionType.memoriesDebug,
hasMore:
(_momentsSearchResults.length >= kSearchSectionLimit - 1),
),
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart
index 64643232c3..935e5c8064 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart
@@ -130,11 +130,16 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
snapshot.data!.elementAt(index)
as List<AlbumSearchResult>,
);
- case SectionType.moment:
- return MomentsSection(
- snapshot.data!.elementAt(index)
- as List<GenericSearchResult>,
- );
+ case SectionType.memoriesDebug:
+ if (flagService.internalUser &&
+ localSettings.isDebugMemoriesEnabled) {
+ return MomentsSection(
+ snapshot.data!.elementAt(index)
+ as List<GenericSearchResult>,
+ );
+ } else {
+ return const SizedBox.shrink();
+ }
case SectionType.location:
return LocationsSection(
snapshot.data!.elementAt(index)
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index 4133bf0087..b5f0031152 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -26,6 +26,7 @@ class LocalSettings {
static const kRateUsShownCount = "rate_us_shown_count";
static const kEnableMultiplePart = "ls.enable_multiple_part";
static const kCuratedMemoriesEnabled = "ls.curated_memories_enabled";
+ static const _kDebugMemoriesEnabled = "ls.debug_memories_enabled";
static const kOnThisDayNotificationsEnabled =
"ls.on_this_day_notifications_enabled";
static const kBirthdayNotificationsEnabled =
@@ -118,11 +119,19 @@ class LocalSettings {
bool get isSmartMemoriesEnabled =>
_prefs.getBool(kCuratedMemoriesEnabled) ?? true;
+ bool get isDebugMemoriesEnabled =>
+ _prefs.getBool(_kDebugMemoriesEnabled) ?? false;
+
Future<bool> setSmartMemories(bool value) async {
await _prefs.setBool(kCuratedMemoriesEnabled, value);
return value;
}
+ Future<bool> toggleDebugMemories() async {
+ await _prefs.setBool(_kDebugMemoriesEnabled, !isDebugMemoriesEnabled);
+ return isDebugMemoriesEnabled;
+ }
+
bool get isOnThisDayNotificationsEnabled =>
_prefs.getBool(kOnThisDayNotificationsEnabled) ?? true;