mirror of
https://github.com/localsend/localsend.git
synced 2026-06-23 04:10:07 +00:00
fix: properly close app on back gesture (#1570)
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## 1.16.0 (unreleased)
|
||||
|
||||
- fix(android): properly close app on back gesture (@Tienisto)
|
||||
|
||||
## 1.15.2 (2024-07-25)
|
||||
|
||||
- feat: extract network scanning to separate threads, scanning should not cause UI lags anymore (@Tienisto)
|
||||
|
||||
+12
-2
@@ -1,3 +1,4 @@
|
||||
import 'package:common/isolate.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:localsend_app/gen/strings.g.dart';
|
||||
@@ -38,8 +39,17 @@ class LocalSendApp extends StatelessWidget {
|
||||
child: WindowWatcher(
|
||||
child: LifeCycleWatcher(
|
||||
onChangedState: (AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
ref.redux(localIpProvider).dispatch(InitLocalIpAction());
|
||||
switch (state) {
|
||||
case AppLifecycleState.resumed:
|
||||
ref.redux(localIpProvider).dispatch(InitLocalIpAction());
|
||||
break;
|
||||
case AppLifecycleState.detached:
|
||||
// The main isolate is only exited when all child isolates are exited.
|
||||
// https://github.com/localsend/localsend/issues/1568
|
||||
ref.redux(parentIsolateProvider).dispatch(IsolateDisposeAction());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
child: ShortcutWatcher(
|
||||
|
||||
@@ -96,3 +96,13 @@ class IsolateSetupAction extends AsyncReduxAction<IsolateController, ParentIsola
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IsolateDisposeAction extends ReduxAction<IsolateController, ParentIsolateState> {
|
||||
@override
|
||||
ParentIsolateState reduce() {
|
||||
state.httpScanDiscovery?.isolate.kill();
|
||||
state.httpTargetDiscovery?.isolate.kill();
|
||||
state.multicastDiscovery?.isolate.kill();
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user