From 819a8ad6d33ebc1fb02520eb9cf34fc633fa9e49 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 13 Sep 2022 14:03:37 +0530 Subject: [PATCH] Debug: Add option to clear ignored files --- lib/services/ignored_files_service.dart | 5 +++++ lib/services/local_sync_service.dart | 2 -- lib/ui/settings/debug_section_widget.dart | 14 ++++++++++++++ lib/ui/settings_page.dart | 4 +++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/services/ignored_files_service.dart b/lib/services/ignored_files_service.dart index 770a0f3c7..3d2f5f787 100644 --- a/lib/services/ignored_files_service.dart +++ b/lib/services/ignored_files_service.dart @@ -74,6 +74,11 @@ class IgnoredFilesService { } } + Future reset() async { + await _db.clearTable(); + _ignoredIDs = null; + } + Future> _loadExistingIDs() async { _logger.fine('loading existing IDs'); final result = await _db.getAll(); diff --git a/lib/services/local_sync_service.dart b/lib/services/local_sync_service.dart index f711f2b3f..7472ca0be 100644 --- a/lib/services/local_sync_service.dart +++ b/lib/services/local_sync_service.dart @@ -13,7 +13,6 @@ import 'package:photos/core/event_bus.dart'; import 'package:photos/db/device_files_db.dart'; import 'package:photos/db/file_updation_db.dart'; import 'package:photos/db/files_db.dart'; -import 'package:photos/db/ignored_files_db.dart'; import 'package:photos/events/backup_folders_updated_event.dart'; import 'package:photos/events/local_photos_updated_event.dart'; import 'package:photos/events/sync_status_update_event.dart'; @@ -308,7 +307,6 @@ class LocalSyncService { Future resetLocalSync() async { assert(kDebugMode, "only available in debug mode"); await FilesDB.instance.deleteDB(); - await IgnoredFilesDB.instance.clearTable(); for (var element in [ kHasCompletedFirstImportKey, hasImportedDeviceCollections, diff --git a/lib/ui/settings/debug_section_widget.dart b/lib/ui/settings/debug_section_widget.dart index 6fe92f138..d1d782ad0 100644 --- a/lib/ui/settings/debug_section_widget.dart +++ b/lib/ui/settings/debug_section_widget.dart @@ -5,7 +5,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_sodium/flutter_sodium.dart'; import 'package:photos/core/configuration.dart'; import 'package:photos/core/network.dart'; +import 'package:photos/services/ignored_files_service.dart'; import 'package:photos/services/local_sync_service.dart'; +import 'package:photos/services/sync_service.dart'; import 'package:photos/ui/settings/common_settings.dart'; import 'package:photos/ui/settings/settings_section_title.dart'; import 'package:photos/ui/settings/settings_text_item.dart'; @@ -57,6 +59,18 @@ class DebugSectionWidget extends StatelessWidget { icon: Icons.navigate_next, ), ), + GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () async { + await IgnoredFilesService.instance.reset(); + SyncService.instance.sync(); + showToast(context, "Done"); + }, + child: const SettingsTextItem( + text: "Allow auto-upload for ignored files", + icon: Icons.navigate_next, + ), + ), ], ); } diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index e50498dc5..5c0811e61 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:photos/core/configuration.dart'; +import 'package:photos/services/feature_flag_service.dart'; import 'package:photos/ui/settings/account_section_widget.dart'; import 'package:photos/ui/settings/app_version_widget.dart'; import 'package:photos/ui/settings/backup_section_widget.dart'; @@ -104,7 +105,8 @@ class SettingsPage extends StatelessWidget { ]); } - if (kDebugMode && hasLoggedIn) { + if (FeatureFlagService.instance.isInternalUserOrDebugBuild() && + hasLoggedIn) { contents.addAll([sectionDivider, const DebugSectionWidget()]); } contents.add(const AppVersionWidget());