mirror of
https://github.com/localsend/localsend.git
synced 2026-08-07 07:14:52 +00:00
fix: correctly set the background flag
This commit is contained in:
@@ -162,7 +162,12 @@ final sendTabVmProvider = ViewProvider((ref) {
|
||||
() => SendPage(showAppBar: true, closeSessionOnClose: false, sessionId: session.sessionId),
|
||||
transition: RouterinoTransition.fade(),
|
||||
);
|
||||
ref.notifier(sendProvider).setBackground(session.sessionId, true);
|
||||
// Only restore background mode if the user actually backed out.
|
||||
// When the receiver accepts, the provider replaces this page with the ProgressPage,
|
||||
// which also resolves this future; the ProgressPage then owns the background flag.
|
||||
if (ref.read(sendProvider)[session.sessionId]?.status == SessionStatus.waiting) {
|
||||
ref.notifier(sendProvider).setBackground(session.sessionId, true);
|
||||
}
|
||||
return;
|
||||
} else if (session.status == SessionStatus.sending || session.status == SessionStatus.finishedWithErrors) {
|
||||
ref.notifier(sendProvider).setBackground(session.sessionId, false);
|
||||
|
||||
@@ -410,16 +410,26 @@ class SendNotifier extends Notifier<Map<String, SendSessionState>> {
|
||||
if (state[sessionId]?.background == false) {
|
||||
final background = ref.read(settingsProvider).sendMode == SendMode.multiple;
|
||||
|
||||
// ignore: use_build_context_synchronously, unawaited_futures
|
||||
Routerino.context.pushAndRemoveUntil(
|
||||
removeUntil: HomePage,
|
||||
transition: RouterinoTransition.fade(),
|
||||
// immediately is not possible: https://github.com/flutter/flutter/issues/121910
|
||||
builder: () => ProgressPage(
|
||||
showAppBar: background,
|
||||
closeSessionOnClose: !background,
|
||||
sessionId: sessionId,
|
||||
),
|
||||
unawaited(
|
||||
// ignore: use_build_context_synchronously
|
||||
Routerino.context
|
||||
.pushAndRemoveUntil(
|
||||
removeUntil: HomePage,
|
||||
transition: RouterinoTransition.fade(),
|
||||
// immediately is not possible: https://github.com/flutter/flutter/issues/121910
|
||||
builder: () => ProgressPage(
|
||||
showAppBar: background,
|
||||
closeSessionOnClose: !background,
|
||||
sessionId: sessionId,
|
||||
),
|
||||
)
|
||||
.then((_) {
|
||||
if (background) {
|
||||
// The page was popped (e.g. backing out mid-transfer), so the session
|
||||
// runs in background again and is removed silently on success.
|
||||
setBackground(sessionId, true);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user