Remove memories debug from sections types

This commit is contained in:
laurenspriem
2025-07-15 13:16:56 +02:00
parent b8d69e79f0
commit 9696409b01
5 changed files with 56 additions and 72 deletions

View File

@@ -13,7 +13,6 @@ import "package:photos/models/collection/collection.dart";
import "package:photos/models/collection/collection_items.dart";
import "package:photos/models/search/search_result.dart";
import "package:photos/models/typedefs.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
import "package:photos/services/search_service.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
@@ -44,10 +43,6 @@ enum SectionType {
face,
magic,
location,
/// WARNING: Not for production purposes, only kept for debugging memories
memoriesDebug,
album,
// People section shows the files shared by other persons
contacts,
@@ -62,8 +57,6 @@ extension SectionTypeExtensions on SectionType {
return S.of(context).people;
case SectionType.magic:
return S.of(context).discover;
case SectionType.memoriesDebug:
return "Debug memories (internal)";
case SectionType.location:
return S.of(context).locations;
case SectionType.contacts:
@@ -81,8 +74,6 @@ extension SectionTypeExtensions on SectionType {
return S.of(context).searchPersonsEmptySection;
case SectionType.magic:
return S.of(context).searchDiscoverEmptySection;
case SectionType.memoriesDebug:
return "For debugging for internal users only";
case SectionType.location:
return S.of(context).searchLocationEmptySection;
case SectionType.contacts:
@@ -100,7 +91,6 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
case SectionType.magic:
case SectionType.memoriesDebug:
case SectionType.fileTypesAndExtension:
return false;
case SectionType.location:
@@ -113,14 +103,12 @@ extension SectionTypeExtensions on SectionType {
bool get sortByName =>
this != SectionType.face &&
this != SectionType.magic &&
this != SectionType.memoriesDebug &&
this != SectionType.contacts;
bool get isEmptyCTAVisible {
switch (this) {
case SectionType.face:
case SectionType.magic:
case SectionType.memoriesDebug:
case SectionType.fileTypesAndExtension:
return false;
case SectionType.location:
@@ -138,8 +126,6 @@ extension SectionTypeExtensions on SectionType {
case SectionType.magic:
// todo: later
return "temp";
case SectionType.memoriesDebug:
return "Test memories";
case SectionType.location:
return S.of(context).addNew;
case SectionType.contacts:
@@ -157,8 +143,6 @@ extension SectionTypeExtensions on SectionType {
return Icons.adaptive.arrow_forward_outlined;
case SectionType.magic:
return null;
case SectionType.memoriesDebug:
return null;
case SectionType.location:
return Icons.add_location_alt_outlined;
case SectionType.contacts:
@@ -236,11 +220,6 @@ extension SectionTypeExtensions on SectionType {
return SearchService.instance.getAllFace(limit);
case SectionType.magic:
return SearchService.instance.getMagicSectionResults(context!);
case SectionType.memoriesDebug:
if (flagService.internalUser && localSettings.isDebugMemoriesEnabled) {
return SearchService.instance.smartMemories(context!, limit);
}
return Future.value([]);
case SectionType.location:
return SearchService.instance.getAllLocationTags(limit);

View File

@@ -37,6 +37,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
Timer? _timer;
bool isExpanded = false;
bool _showMemoriesDebugSection = false;
bool _showAllMemories = false;
final Logger logger = Logger("MLDebugSectionWidget");
late final mlDataDB = MLDataDB.instance;
@override
@@ -603,12 +604,21 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
if (_showMemoriesDebugSection) sectionOptionSpacing,
if (_showMemoriesDebugSection)
FutureBuilder<List<GenericSearchResult>>(
future: SearchService.instance
.smartMemories(context, kSearchSectionLimit),
key: ValueKey(_showAllMemories),
future: SearchService.instance.smartMemories(
context,
_showAllMemories ? null : kSearchSectionLimit,
),
builder: (context, snapshot) {
if (snapshot.hasData) {
final memories = snapshot.data!;
return MemoriesDebugSection(memories);
return MemoriesDebugSection(memories, () async {
_showAllMemories = !_showAllMemories;
_timer?.cancel();
if (mounted) {
setState(() {});
}
});
}
return const SizedBox.shrink();
},

View File

@@ -3,22 +3,22 @@ import "dart:math";
import "package:figma_squircle/figma_squircle.dart";
import "package:flutter/material.dart";
import "package:photos/core/constants.dart";
import "package:photos/events/event.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/models/search/recent_searches.dart";
import "package:photos/models/search/search_types.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
import "package:photos/ui/viewer/search/result/search_result_page.dart";
import "package:photos/ui/viewer/search/search_section_cta.dart";
import "package:photos/ui/viewer/search_tab/section_header.dart";
import "package:photos/utils/navigation_util.dart";
class MemoriesDebugSection extends StatefulWidget {
final List<GenericSearchResult> momentsSearchResults;
const MemoriesDebugSection(this.momentsSearchResults, {super.key});
final VoidCallback onTapCallback;
const MemoriesDebugSection(
this.momentsSearchResults,
this.onTapCallback, {
super.key,
});
@override
State<MemoriesDebugSection> createState() => _MemoriesDebugSectionState();
@@ -32,19 +32,6 @@ class _MemoriesDebugSectionState extends State<MemoriesDebugSection> {
void initState() {
super.initState();
_momentsSearchResults = widget.momentsSearchResults;
final streamsToListenTo = SectionType.memoriesDebug.sectionUpdateEvents();
for (Stream<Event> stream in streamsToListenTo) {
streamSubscriptions.add(
stream.listen((event) async {
_momentsSearchResults = (await SectionType.memoriesDebug.getData(
context,
limit: kSearchSectionLimit,
)) as List<GenericSearchResult>;
setState(() {});
}),
);
}
}
@override
@@ -74,14 +61,14 @@ class _MemoriesDebugSectionState extends State<MemoriesDebugSection> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
SectionType.memoriesDebug.sectionTitle(context),
"Smart memories debug (I)",
style: textTheme.largeBold,
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 4),
child: Text(
SectionType.memoriesDebug.getEmptyStateText(context),
"Test memories",
style: textTheme.smallMuted,
),
),
@@ -89,7 +76,6 @@ class _MemoriesDebugSectionState extends State<MemoriesDebugSection> {
),
),
const SizedBox(width: 8),
const SearchSectionEmptyCTAIcon(SectionType.memoriesDebug),
],
),
);
@@ -99,11 +85,7 @@ class _MemoriesDebugSectionState extends State<MemoriesDebugSection> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SectionHeader(
SectionType.memoriesDebug,
hasMore:
(_momentsSearchResults.length >= kSearchSectionLimit - 1),
),
_SectionHeader(widget.onTapCallback),
const SizedBox(height: 2),
SizedBox(
child: SingleChildScrollView(
@@ -129,6 +111,40 @@ class _MemoriesDebugSectionState extends State<MemoriesDebugSection> {
}
}
class _SectionHeader extends StatelessWidget {
final VoidCallback onTapCallback;
const _SectionHeader(this.onTapCallback);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTapCallback,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(12),
child: Text(
"Smart memories debug (I)",
style: getEnteTextTheme(context).largeBold,
),
),
Container(
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 12, 12, 12),
child: Icon(
Icons.chevron_right_outlined,
color: getEnteColorScheme(context).blurStrokePressed,
),
),
),
],
),
);
}
}
class MomentRecommendation extends StatelessWidget {
static const _width = 100.0;
static const _height = 145.0;

View File

@@ -19,7 +19,6 @@ import 'package:photos/ui/viewer/search_tab/albums_section.dart';
import "package:photos/ui/viewer/search_tab/file_type_section.dart";
import "package:photos/ui/viewer/search_tab/locations_section.dart";
import "package:photos/ui/viewer/search_tab/magic_section.dart";
import "package:photos/ui/viewer/search_tab/memories_debug_section.dart";
import "package:photos/ui/viewer/search_tab/people_section.dart";
class SearchTab extends StatefulWidget {
@@ -125,21 +124,10 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
as List<GenericSearchResult>,
);
case SectionType.album:
// return const SizedBox.shrink();
return AlbumsSection(
snapshot.data!.elementAt(index)
as List<AlbumSearchResult>,
);
case SectionType.memoriesDebug:
if (flagService.internalUser &&
localSettings.isDebugMemoriesEnabled) {
return MemoriesDebugSection(
snapshot.data!.elementAt(index)
as List<GenericSearchResult>,
);
} else {
return const SizedBox.shrink();
}
case SectionType.location:
return LocationsSection(
snapshot.data!.elementAt(index)

View File

@@ -26,7 +26,6 @@ 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 =
@@ -119,19 +118,11 @@ 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;