Skip to content

armgit / ente

Public Imported from GitHub
0

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

Replace configurable thumbnail queue settings with hardcoded values

ashilkn262565d5f9c2
diff --git a/mobile/apps/photos/lib/core/configuration.dart b/mobile/apps/photos/lib/core/configuration.dart
index 4c079f5f25..d18aadf6c6 100644
--- a/mobile/apps/photos/lib/core/configuration.dart
+++ b/mobile/apps/photos/lib/core/configuration.dart
@@ -108,11 +108,14 @@ class Configuration {
_documentsDirectory + "/ente-shared-media";
Directory(_sharedDocumentsMediaDirectory).createSync(recursive: true);
if (!_preferences.containsKey(tokenKey)) {
- _logger
- .info("(for debugging) Token not found, deleting all secure storage data");
+ _logger.info(
+ "(for debugging) Token not found, deleting all secure storage data",
+ );
await _secureStorage.deleteAll();
} else {
- _logger.info("(for debugging) Token found, loading secure storage data");
+ _logger.info(
+ "(for debugging) Token found, loading secure storage data",
+ );
_key = await _secureStorage.read(
key: keyKey,
);
@@ -702,7 +705,9 @@ class Configuration {
}
Future<void> _migrateSecurityStorageToFirstUnlock() async {
- _logger.info("(for debugging) Migrating secure storage to first unlock if needed");
+ _logger.info(
+ "(for debugging) Migrating secure storage to first unlock if needed",
+ );
final hasMigratedSecureStorage =
_preferences.getBool(hasMigratedSecureStorageKey) ?? false;
if (!hasMigratedSecureStorage && _key != null && _secretKey != null) {
diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dart
index d581da7b0a..b1b6868492 100644
--- a/mobile/apps/photos/lib/services/collections_service.dart
+++ b/mobile/apps/photos/lib/services/collections_service.dart
@@ -867,7 +867,9 @@ class CollectionsService {
publicUrl = publicUrl.replace(
host: embedUri.host,
scheme: embedUri.scheme,
- port: embedUri.hasPort ? embedUri.port : (embedUri.scheme == 'https' ? 443 : 80),
+ port: embedUri.hasPort
+ ? embedUri.port
+ : (embedUri.scheme == 'https' ? 443 : 80),
);
}
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.dart
index 4e9d15964d..b5497bc93e 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,8 +12,6 @@ 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/local_thumbnail_config_screen.dart';
-import 'package:photos/utils/navigation_util.dart';
class DebugSectionWidget extends StatefulWidget {
const DebugSectionWidget({super.key});
@@ -79,21 +77,6 @@ class _DebugSectionWidgetState extends State<DebugSectionWidget> {
),
),
sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: const CaptionedTextWidget(
- title: "Local thumbnail queue config",
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- await routeToPage(
- context,
- const LocalThumbnailConfigScreen(),
- );
- },
- ),
- sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Key attributes",
diff --git a/mobile/apps/photos/lib/ui/settings/debug/local_thumbnail_config_screen.dart b/mobile/apps/photos/lib/ui/settings/debug/local_thumbnail_config_screen.dart
deleted file mode 100644
index 470bff8ef1..0000000000
--- a/mobile/apps/photos/lib/ui/settings/debug/local_thumbnail_config_screen.dart
+++ /dev/null
@@ -1,350 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:logging/logging.dart';
-import 'package:photos/service_locator.dart';
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/components/title_bar_title_widget.dart';
-import 'package:photos/ui/notification/toast.dart';
-
-class LocalThumbnailConfigScreen extends StatefulWidget {
- const LocalThumbnailConfigScreen({super.key});
-
- @override
- State<LocalThumbnailConfigScreen> createState() =>
- _LocalThumbnailConfigScreenState();
-}
-
-class _LocalThumbnailConfigScreenState
- extends State<LocalThumbnailConfigScreen> {
- static final Logger _logger = Logger("LocalThumbnailConfigScreen");
-
- late TextEditingController _smallMaxConcurrentController;
- late TextEditingController _smallTimeoutController;
- late TextEditingController _smallMaxSizeController;
- late TextEditingController _largeMaxConcurrentController;
- late TextEditingController _largeTimeoutController;
- late TextEditingController _largeMaxSizeController;
-
- @override
- void initState() {
- super.initState();
- _initControllers();
- }
-
- void _initControllers() {
- _smallMaxConcurrentController = TextEditingController(
- text: localSettings.smallQueueMaxConcurrent.toString(),
- );
- _smallTimeoutController = TextEditingController(
- text: localSettings.smallQueueTimeoutSeconds.toString(),
- );
- _smallMaxSizeController = TextEditingController(
- text: localSettings.smallQueueMaxSize.toString(),
- );
- _largeMaxConcurrentController = TextEditingController(
- text: localSettings.largeQueueMaxConcurrent.toString(),
- );
- _largeTimeoutController = TextEditingController(
- text: localSettings.largeQueueTimeoutSeconds.toString(),
- );
- _largeMaxSizeController = TextEditingController(
- text: localSettings.largeQueueMaxSize.toString(),
- );
- }
-
- @override
- void dispose() {
- _smallMaxConcurrentController.dispose();
- _smallTimeoutController.dispose();
- _smallMaxSizeController.dispose();
- _largeMaxConcurrentController.dispose();
- _largeTimeoutController.dispose();
- _largeMaxSizeController.dispose();
- super.dispose();
- }
-
- Future<void> _saveSettings() async {
- try {
- // Validate and save small queue settings
- final smallMaxConcurrent =
- int.tryParse(_smallMaxConcurrentController.text);
- final smallTimeout = int.tryParse(_smallTimeoutController.text);
- final smallMaxSize = int.tryParse(_smallMaxSizeController.text);
-
- // Validate and save large queue settings
- final largeMaxConcurrent =
- int.tryParse(_largeMaxConcurrentController.text);
- final largeTimeout = int.tryParse(_largeTimeoutController.text);
- final largeMaxSize = int.tryParse(_largeMaxSizeController.text);
-
- if (smallMaxConcurrent == null ||
- smallTimeout == null ||
- smallMaxSize == null ||
- largeMaxConcurrent == null ||
- largeTimeout == null ||
- largeMaxSize == null) {
- showShortToast(context, "Please enter valid numbers");
- return;
- }
-
- // Basic validation - just ensure positive numbers
- if (smallMaxConcurrent < 1 ||
- largeMaxConcurrent < 1 ||
- smallTimeout < 1 ||
- largeTimeout < 1 ||
- smallMaxSize < 1 ||
- largeMaxSize < 1) {
- showShortToast(
- context,
- "All values must be positive numbers",
- );
- return;
- }
-
- await localSettings.setSmallQueueMaxConcurrent(smallMaxConcurrent);
- await localSettings.setSmallQueueTimeout(smallTimeout);
- await localSettings.setSmallQueueMaxSize(smallMaxSize);
- await localSettings.setLargeQueueMaxConcurrent(largeMaxConcurrent);
- await localSettings.setLargeQueueTimeout(largeTimeout);
- await localSettings.setLargeQueueMaxSize(largeMaxSize);
-
- _logger.info(
- "Local thumbnail queue settings updated:\n"
- "Small Queue - MaxConcurrent: $smallMaxConcurrent, Timeout: ${smallTimeout}s, MaxSize: $smallMaxSize\n"
- "Large Queue - MaxConcurrent: $largeMaxConcurrent, Timeout: ${largeTimeout}s, MaxSize: $largeMaxSize",
- );
-
- if (mounted) {
- showShortToast(
- context,
- "Settings saved. Restart app to apply changes.",
- );
- }
- } catch (e) {
- showShortToast(context, "Error saving settings");
- }
- }
-
- Future<void> _resetToDefaults() async {
- await localSettings.resetThumbnailQueueSettings();
- setState(() {
- _smallMaxConcurrentController.text = "15";
- _smallTimeoutController.text = "60";
- _smallMaxSizeController.text = "200";
- _largeMaxConcurrentController.text = "5";
- _largeTimeoutController.text = "60";
- _largeMaxSizeController.text = "200";
- });
-
- _logger.info(
- "Local thumbnail queue settings reset to defaults:\n"
- "Small Queue - MaxConcurrent: 15, Timeout: 60s, MaxSize: 200\n"
- "Large Queue - MaxConcurrent: 5, Timeout: 60s, MaxSize: 200",
- );
-
- if (mounted) {
- showShortToast(
- context,
- "Reset to defaults. Restart app to apply changes.",
- );
- }
- }
-
- Widget _buildNumberField({
- required String label,
- required String hint,
- required TextEditingController controller,
- }) {
- return Padding(
- padding: const EdgeInsets.symmetric(vertical: 8.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- label,
- style: getEnteTextTheme(context).body.copyWith(
- color: getEnteColorScheme(context).textMuted,
- ),
- ),
- const SizedBox(height: 4),
- TextField(
- controller: controller,
- keyboardType: TextInputType.number,
- inputFormatters: [FilteringTextInputFormatter.digitsOnly],
- decoration: InputDecoration(
- hintText: hint,
- hintStyle: getEnteTextTheme(context).body.copyWith(
- color: getEnteColorScheme(context).textFaint,
- ),
- filled: true,
- fillColor: getEnteColorScheme(context).fillFaint,
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(8),
- borderSide: BorderSide.none,
- ),
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 12,
- vertical: 8,
- ),
- ),
- style: getEnteTextTheme(context).body,
- ),
- ],
- ),
- );
- }
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- return Scaffold(
- body: Container(
- color: colorScheme.backdropBase,
- child: SafeArea(
- child: Column(
- children: [
- const TitleBarTitleWidget(
- title: "Local Thumbnail Queue Config",
- ),
- Expanded(
- child: SingleChildScrollView(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "Small Local Thumbnail Queue",
- style: getEnteTextTheme(context).largeBold,
- ),
- const SizedBox(height: 8),
- Text(
- "Used when gallery grid has 4 or more columns",
- style: getEnteTextTheme(context).small.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- const SizedBox(height: 16),
- _buildNumberField(
- label: "Max Concurrent Tasks",
- hint: "Default: 15",
- controller: _smallMaxConcurrentController,
- ),
- _buildNumberField(
- label: "Timeout (seconds)",
- hint: "Default: 60",
- controller: _smallTimeoutController,
- ),
- _buildNumberField(
- label: "Max Queue Size",
- hint: "Default: 200",
- controller: _smallMaxSizeController,
- ),
- const SizedBox(height: 32),
- Text(
- "Large Local Thumbnail Queue",
- style: getEnteTextTheme(context).largeBold,
- ),
- const SizedBox(height: 8),
- Text(
- "Used when gallery grid has less than 4 columns",
- style: getEnteTextTheme(context).small.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- const SizedBox(height: 16),
- _buildNumberField(
- label: "Max Concurrent Tasks",
- hint: "Default: 5",
- controller: _largeMaxConcurrentController,
- ),
- _buildNumberField(
- label: "Timeout (seconds)",
- hint: "Default: 60",
- controller: _largeTimeoutController,
- ),
- _buildNumberField(
- label: "Max Queue Size",
- hint: "Default: 200",
- controller: _largeMaxSizeController,
- ),
- const SizedBox(height: 32),
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- onPressed: _saveSettings,
- style: ElevatedButton.styleFrom(
- backgroundColor: colorScheme.primary700,
- padding: const EdgeInsets.symmetric(vertical: 12),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- child: Text(
- "Save Settings",
- style: getEnteTextTheme(context).bodyBold.copyWith(
- color: Colors.white,
- ),
- ),
- ),
- ),
- const SizedBox(height: 12),
- SizedBox(
- width: double.infinity,
- child: TextButton(
- onPressed: _resetToDefaults,
- style: TextButton.styleFrom(
- foregroundColor: colorScheme.primary700,
- padding: const EdgeInsets.symmetric(vertical: 12),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- side: BorderSide(
- color: colorScheme.strokeMuted,
- ),
- ),
- ),
- child: const Text(
- "Reset to Defaults",
- style: TextStyle(
- fontWeight: FontWeight.w600,
- fontSize: 14,
- ),
- ),
- ),
- ),
- const SizedBox(height: 16),
- Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Row(
- children: [
- Icon(
- Icons.info_outline,
- size: 20,
- color: colorScheme.textMuted,
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- "Changes require app restart to take effect",
- style: getEnteTextTheme(context).small.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart
index f16d62c37c..eb412cc938 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart
@@ -129,9 +129,9 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
static final TaskQueue<String> largeLocalThumbnailQueue = _initLargeQueue();
static TaskQueue<String> _initSmallQueue() {
- final maxConcurrent = localSettings.smallQueueMaxConcurrent;
- final timeoutSeconds = localSettings.smallQueueTimeoutSeconds;
- final maxSize = localSettings.smallQueueMaxSize;
+ const maxConcurrent = 45;
+ const timeoutSeconds = 60;
+ const maxSize = 200;
_logger.info(
"Initializing Small Local Thumbnail Queue - "
@@ -146,9 +146,9 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
}
static TaskQueue<String> _initLargeQueue() {
- final maxConcurrent = localSettings.largeQueueMaxConcurrent;
- final timeoutSeconds = localSettings.largeQueueTimeoutSeconds;
- final maxSize = localSettings.largeQueueMaxSize;
+ const maxConcurrent = 15;
+ const timeoutSeconds = 60;
+ const maxSize = 200;
_logger.info(
"Initializing Large Local Thumbnail Queue - "
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index aecbf4ab3f..3c6178cb13 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -792,7 +792,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
await flagService.setMapEnabled(true);
} catch (e) {
showShortToast(
- context, AppLocalizations.of(context).somethingWentWrong,);
+ context,
+ AppLocalizations.of(context).somethingWentWrong,
+ );
return;
}
}
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index 13b541fbeb..208621a008 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -46,14 +46,6 @@ class LocalSettings {
static const kShowLocalIDOverThumbnails = "show_local_id_over_thumbnails";
static const kEnableDatabaseLogging = "enable_db_logging";
- // Thumbnail queue configuration keys
- static const kSmallQueueMaxConcurrent = "small_queue_max_concurrent";
- static const kSmallQueueTimeout = "small_queue_timeout_seconds";
- static const kSmallQueueMaxSize = "small_queue_max_size";
- static const kLargeQueueMaxConcurrent = "large_queue_max_concurrent";
- static const kLargeQueueTimeout = "large_queue_timeout_seconds";
- static const kLargeQueueMaxSize = "large_queue_max_size";
-
final SharedPreferences _prefs;
LocalSettings(this._prefs);
@@ -243,54 +235,4 @@ class LocalSettings {
Future<void> setEnableDatabaseLogging(bool value) async {
await _prefs.setBool(kEnableDatabaseLogging, value);
}
-
- // Thumbnail queue configuration - Small queue
- int get smallQueueMaxConcurrent =>
- _prefs.getInt(kSmallQueueMaxConcurrent) ?? 15;
-
- int get smallQueueTimeoutSeconds => _prefs.getInt(kSmallQueueTimeout) ?? 60;
-
- int get smallQueueMaxSize => _prefs.getInt(kSmallQueueMaxSize) ?? 200;
-
- Future<void> setSmallQueueMaxConcurrent(int value) async {
- await _prefs.setInt(kSmallQueueMaxConcurrent, value);
- }
-
- Future<void> setSmallQueueTimeout(int seconds) async {
- await _prefs.setInt(kSmallQueueTimeout, seconds);
- }
-
- Future<void> setSmallQueueMaxSize(int value) async {
- await _prefs.setInt(kSmallQueueMaxSize, value);
- }
-
- // Thumbnail queue configuration - Large queue
- int get largeQueueMaxConcurrent =>
- _prefs.getInt(kLargeQueueMaxConcurrent) ?? 5;
-
- int get largeQueueTimeoutSeconds => _prefs.getInt(kLargeQueueTimeout) ?? 60;
-
- int get largeQueueMaxSize => _prefs.getInt(kLargeQueueMaxSize) ?? 200;
-
- Future<void> setLargeQueueMaxConcurrent(int value) async {
- await _prefs.setInt(kLargeQueueMaxConcurrent, value);
- }
-
- Future<void> setLargeQueueTimeout(int seconds) async {
- await _prefs.setInt(kLargeQueueTimeout, seconds);
- }
-
- Future<void> setLargeQueueMaxSize(int value) async {
- await _prefs.setInt(kLargeQueueMaxSize, value);
- }
-
- // Reset thumbnail queue settings to defaults
- Future<void> resetThumbnailQueueSettings() async {
- await _prefs.remove(kSmallQueueMaxConcurrent);
- await _prefs.remove(kSmallQueueTimeout);
- await _prefs.remove(kSmallQueueMaxSize);
- await _prefs.remove(kLargeQueueMaxConcurrent);
- await _prefs.remove(kLargeQueueTimeout);
- await _prefs.remove(kLargeQueueMaxSize);
- }
}