π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add social debug screen with seed and delete comments options
ashilkn0b760ccfc86b
diff --git a/mobile/apps/photos/lib/db/social_db.dart b/mobile/apps/photos/lib/db/social_db.dartindex cf7a4e2eac..cf7037c038 100644--- a/mobile/apps/photos/lib/db/social_db.dart+++ b/mobile/apps/photos/lib/db/social_db.dart@@ -162,6 +162,65 @@ class SocialDB {return rows.map(_rowToComment).toList();}+ /// Fetch a single comment by ID (for parent lookup)+ Future<Comment?> getCommentById(String id) async {+ final db = await database;+ final rows = await db.query(+ commentsTable,+ where: 'id = ? AND is_deleted = 0',+ whereArgs: [id],+ );+ if (rows.isEmpty) return null;+ return _rowToComment(rows.first);+ }++ /// Paginated fetch for file comments+ Future<List<Comment>> getCommentsForFilePaginated(+ int fileID, {+ int limit = 20,+ int offset = 0,+ }) async {+ final db = await database;+ final rows = await db.query(+ commentsTable,+ where: 'file_id = ? AND is_deleted = 0',+ whereArgs: [fileID],+ orderBy: 'created_at DESC',+ limit: limit,+ offset: offset,+ );+ return rows.map(_rowToComment).toList();+ }++ /// Paginated fetch for collection comments+ Future<List<Comment>> getCommentsForCollectionPaginated(+ int collectionID, {+ int limit = 20,+ int offset = 0,+ }) async {+ final db = await database;+ final rows = await db.query(+ commentsTable,+ where: 'collection_id = ? AND file_id IS NULL AND is_deleted = 0',+ whereArgs: [collectionID],+ orderBy: 'created_at DESC',+ limit: limit,+ offset: offset,+ );+ return rows.map(_rowToComment).toList();+ }++ /// Delete all comments from the database+ Future<int> deleteAllComments() async {+ final db = await database;+ final deletedCount = await db.delete(commentsTable);+ _logger.info('Deleted $deletedCount comments');+ return deletedCount;+ }++ /// Seeds the database with example comments and reactions for testing.+ Future<void> seedExampleData() async {}+// Reaction methodsFuture<Reaction?> addReaction(Reaction reaction) async {diff --git a/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart b/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dartindex da53e4fd42..91f9e5cc5f 100644--- a/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart+++ b/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart@@ -12,6 +12,8 @@ import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';import 'package:photos/ui/components/toggle_switch_widget.dart';import 'package:photos/ui/notification/toast.dart';import 'package:photos/ui/settings/common_settings.dart';+import 'package:photos/ui/settings/debug/social_debug_screen.dart';+import 'package:photos/utils/navigation_util.dart';class DebugSectionWidget extends StatefulWidget {const DebugSectionWidget({super.key});@@ -137,6 +139,18 @@ class _DebugSectionWidgetState extends State<DebugSectionWidget> {showShortToast(context, "Done");},),+ sectionOptionSpacing,+ MenuItemWidget(+ captionedTextWidget: const CaptionedTextWidget(+ title: "Social settings",+ ),+ pressedColor: getEnteColorScheme(context).fillFaint,+ trailingIcon: Icons.chevron_right_outlined,+ trailingIconIsMuted: true,+ onTap: () async {+ await routeToPage(context, const SocialDebugScreen());+ },+ ),],);}diff --git a/mobile/apps/photos/lib/ui/settings/debug/social_debug_screen.dart b/mobile/apps/photos/lib/ui/settings/debug/social_debug_screen.dartnew file mode 100644index 0000000000..026bfa2298--- /dev/null+++ b/mobile/apps/photos/lib/ui/settings/debug/social_debug_screen.dart@@ -0,0 +1,89 @@+import 'package:flutter/material.dart';+import 'package:photos/db/social_db.dart';+import 'package:photos/theme/ente_theme.dart';+import 'package:photos/ui/components/buttons/icon_button_widget.dart';+import 'package:photos/ui/components/captioned_text_widget.dart';+import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';+import 'package:photos/ui/components/title_bar_title_widget.dart';+import 'package:photos/ui/components/title_bar_widget.dart';+import 'package:photos/ui/notification/toast.dart';++class SocialDebugScreen extends StatelessWidget {+ const SocialDebugScreen({super.key});++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ return Scaffold(+ body: CustomScrollView(+ primary: false,+ slivers: <Widget>[+ TitleBarWidget(+ flexibleSpaceTitle: const TitleBarTitleWidget(+ title: "Social debug",+ ),+ actionIcons: [+ IconButtonWidget(+ icon: Icons.close_outlined,+ iconButtonType: IconButtonType.secondary,+ onTap: () {+ Navigator.pop(context);+ },+ ),+ ],+ ),+ SliverList(+ delegate: SliverChildBuilderDelegate(+ (delegateBuildContext, index) {+ return Padding(+ padding:+ const EdgeInsets.symmetric(horizontal: 16, vertical: 20),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ MenuItemWidget(+ captionedTextWidget: const CaptionedTextWidget(+ title: "Seed example data",+ ),+ menuItemColor: colorScheme.fillFaint,+ trailingWidget: Icon(+ Icons.chevron_right_outlined,+ color: colorScheme.strokeBase,+ ),+ singleBorderRadius: 8,+ alignCaptionedTextToLeft: true,+ onTap: () async {+ await SocialDB.instance.seedExampleData();+ showShortToast(context, "Example data seeded");+ },+ ),+ const SizedBox(height: 24),+ MenuItemWidget(+ captionedTextWidget: const CaptionedTextWidget(+ title: "Delete all comments",+ ),+ menuItemColor: colorScheme.fillFaint,+ trailingWidget: Icon(+ Icons.chevron_right_outlined,+ color: colorScheme.strokeBase,+ ),+ singleBorderRadius: 8,+ alignCaptionedTextToLeft: true,+ onTap: () async {+ final count =+ await SocialDB.instance.deleteAllComments();+ showShortToast(context, "Deleted $count comments");+ },+ ),+ ],+ ),+ );+ },+ childCount: 1,+ ),+ ),+ ],+ ),+ );+ }+}