fix: correctly set the background flag

This commit is contained in:
Tien Do Nam
2026-08-04 02:48:46 +02:00
parent 60d4fbb6de
commit 276bd39b1c
2 changed files with 26 additions and 11 deletions
+5
View File
@@ -162,7 +162,12 @@ final sendTabVmProvider = ViewProvider((ref) {
() => SendPage(showAppBar: true, closeSessionOnClose: false, sessionId: session.sessionId),
transition: RouterinoTransition.fade(),
);
// 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);
+12 -2
View File
@@ -410,8 +410,10 @@ 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(
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
@@ -420,6 +422,14 @@ class SendNotifier extends Notifier<Map<String, SendSessionState>> {
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);
}
}),
);
}