An open-source cross-platform alternative to AirDrop
feat: add automatic migration from legacy auto start
Tien Do Nam6ed92afa5b36
diff --git a/app/lib/provider/persistence_provider.dart b/app/lib/provider/persistence_provider.dartindex f527b6aa..56dc8526 100644--- a/app/lib/provider/persistence_provider.dart+++ b/app/lib/provider/persistence_provider.dart@@ -11,6 +11,7 @@ import 'package:localsend_app/model/persistence/receive_history_entry.dart';import 'package:localsend_app/model/send_mode.dart';import 'package:localsend_app/provider/window_dimensions_provider.dart';import 'package:localsend_app/util/alias_generator.dart';+import 'package:localsend_app/util/native/autostart_helper.dart';import 'package:localsend_app/util/native/platform_check.dart';import 'package:localsend_app/util/security_helper.dart';import 'package:localsend_app/util/shared_preferences_portable.dart';@@ -59,7 +60,6 @@ const _saveToHistory = 'ls_save_to_history';const _quickSave = 'ls_quick_save';const _autoFinish = 'ls_auto_finish';const _minimizeToTray = 'ls_minimize_to_tray';-const _launchAtStartup = 'ls_launch_at_startup';const _https = 'ls_https';const _sendMode = 'ls_send_mode';const _enableAnimations = 'ls_enable_animations';@@ -135,6 +135,15 @@ class PersistenceService {}}+ // migrate legacy auto start settings (current implementation is stateless and relies on the Windows registry / file system)+ const launchAtStartupLegacyKey = 'ls_launch_at_startup';+ const launchMinimizedLegacyKey = 'ls_auto_start_launch_minimized';+ if (prefs.getBool(launchAtStartupLegacyKey) == true) {+ await prefs.remove(launchAtStartupLegacyKey);+ await enableAutoStart(startHidden: prefs.getBool(launchMinimizedLegacyKey) == true);+ await prefs.remove(launchMinimizedLegacyKey);+ }+return PersistenceService._(prefs);}@@ -308,14 +317,6 @@ class PersistenceService {await _prefs.setBool(_minimizeToTray, minimizeToTray);}- bool isLaunchAtStartup() {- return _prefs.getBool(_launchAtStartup) ?? false;- }-- Future<void> setLaunchAtStartup(bool launchAtStartup) async {- await _prefs.setBool(_launchAtStartup, launchAtStartup);- }-bool isHttps() {return _prefs.getBool(_https) ?? true;}diff --git a/app/lib/util/native/autostart_helper.dart b/app/lib/util/native/autostart_helper.dartindex 49c4d82f..b2f2fc67 100644--- a/app/lib/util/native/autostart_helper.dart+++ b/app/lib/util/native/autostart_helper.dart@@ -57,7 +57,6 @@ Terminal=false''');return true;case TargetPlatform.windows:- // launch_at_startup does not add quotes around the executable path_getWindowsRegistryKey().createValue(RegistryValue(_windowsRegistryKeyValue,RegistryValueType.string,diff --git a/app/test/mocks.mocks.dart b/app/test/mocks.mocks.dartindex 72e2a500..9f762f35 100644--- a/app/test/mocks.mocks.dart+++ b/app/test/mocks.mocks.dart@@ -423,26 +423,6 @@ class MockPersistenceService extends _i1.Mock implements _i3.PersistenceServicereturnValueForMissingStub: _i4.Future<void>.value(),) as _i4.Future<void>);- @override- bool isLaunchAtStartup() => (super.noSuchMethod(- Invocation.method(- #isLaunchAtStartup,- [],- ),- returnValue: false,- returnValueForMissingStub: false,- ) as bool);-- @override- _i4.Future<void> setLaunchAtStartup(bool? launchAtStartup) => (super.noSuchMethod(- Invocation.method(- #setLaunchAtStartup,- [launchAtStartup],- ),- returnValue: _i4.Future<void>.value(),- returnValueForMissingStub: _i4.Future<void>.value(),- ) as _i4.Future<void>);-@overridebool isHttps() => (super.noSuchMethod(Invocation.method(