fixed stale state after logout and replayed or lost share intents

This commit is contained in:
2026-09-24 21:43:21 +02:00
parent e4e2b1a4fb
commit 498d195138
32 changed files with 743 additions and 188 deletions
+5
View File
@@ -11,6 +11,7 @@ import '../../api/marianumconnect/auth/token_storage.dart';
import '../../api/marianumconnect/queries/auth_login/auth_login.dart';
import '../../api/marianumconnect/queries/auth_logout/auth_logout.dart';
import '../../model/account_data.dart';
import '../../model/session_wipe.dart';
import '../../widget_data/widget_sync.dart';
/// Outcome of a login attempt.
@@ -46,6 +47,10 @@ class LoginController extends ChangeNotifier {
_errorDetails = null;
notifyListeners();
// The previous account's wipe runs deferred; racing it would let it
// clear what this login stores (widget job, caches).
await SessionWipe.done;
final user = username.trim().toLowerCase();
// Demo login: the prefix enters local demo mode, password ignored, no
+9 -15
View File
@@ -53,15 +53,6 @@ class _FilesUploadDialogState extends State<FilesUploadDialog> {
}).toList();
}
void showHttpErrorCode(int httpErrorCode) {
InfoDialog.show(
context,
'Error code: $httpErrorCode',
title: 'Ein Fehler ist aufgetreten',
copyable: true,
);
}
void _resetProgress() {
_isUploading = false;
_overallProgressValue = 0.0;
@@ -221,14 +212,17 @@ class _FilesUploadDialogState extends State<FilesUploadDialog> {
return;
}
if (!mounted) return;
// Stay on the dialog: popping here reported the partial result as a
// success to onUploadFinished and closed the error dialog right away.
if (uploadTask.statusCode < 200 || uploadTask.statusCode > 299) {
setState(_resetProgress);
if (!mounted) return;
Navigator.of(context).pop();
showHttpErrorCode(uploadTask.statusCode);
} else {
uploadetFilePaths.add(fullRemotePath);
_showUploadError(
'Upload fehlgeschlagen für "$fileName" '
'(Fehlercode ${uploadTask.statusCode}).',
);
return;
}
uploadetFilePaths.add(fullRemotePath);
}
setState(_resetProgress);
@@ -135,19 +135,24 @@ Future<void> _externalShareFlow(
PendingShare share,
) async {
if (share.hasFiles) {
await ensureTalkShareFolder();
if (!context.mounted) return;
await pushScreen(
context,
withNavBar: false,
screen: FilesUploadDialog(
filePaths: share.filePaths,
remotePath: talkShareFolder,
uniqueNames: true,
onUploadFinished: (uploaded) =>
_afterExternalFilesUploaded(context, room, uploaded, share),
),
);
ShareIntentListener.instance.beginFlow();
try {
await ensureTalkShareFolder();
if (!context.mounted) return;
await pushScreen(
context,
withNavBar: false,
screen: FilesUploadDialog(
filePaths: share.filePaths,
remotePath: talkShareFolder,
uniqueNames: true,
onUploadFinished: (uploaded) =>
_afterExternalFilesUploaded(context, room, uploaded, share),
),
);
} finally {
ShareIntentListener.instance.endFlow();
}
return;
}
if (share.hasText) {
@@ -155,17 +160,28 @@ Future<void> _externalShareFlow(
}
}
// Called synchronously when the upload dialog pops, so the flow is entered
// before the upload step above releases it.
Future<void> _afterExternalFilesUploaded(
BuildContext context,
GetRoomResponseObject room,
List<String> uploadedRemotePaths,
PendingShare share,
) => _runShareFlow(
context,
action: () =>
shareFilesToChat(token: room.token, remoteFilePaths: uploadedRemotePaths),
onSuccess: () => _setExternalDraftAndOpenChat(context, room, share),
);
) async {
ShareIntentListener.instance.beginFlow();
try {
await _runShareFlow(
context,
action: () => shareFilesToChat(
token: room.token,
remoteFilePaths: uploadedRemotePaths,
),
onSuccess: () => _setExternalDraftAndOpenChat(context, room, share),
);
} finally {
ShareIntentListener.instance.endFlow();
}
}
/// Shared share-flow scaffolding: shows the blocking spinner, runs [action],
/// maps failures to an error dialog (popping the spinner first), and invokes
@@ -206,16 +206,21 @@ Future<void> _externalUploadFlow(
List<String> targetPath,
PendingShare share,
) async {
await pushScreen(
context,
withNavBar: false,
screen: FilesUploadDialog(
filePaths: share.filePaths,
remotePath: targetPath.join('/'),
onUploadFinished: (_) =>
_afterExternalUploaded(context, targetPath, share),
),
);
ShareIntentListener.instance.beginFlow();
try {
await pushScreen(
context,
withNavBar: false,
screen: FilesUploadDialog(
filePaths: share.filePaths,
remotePath: targetPath.join('/'),
onUploadFinished: (_) =>
_afterExternalUploaded(context, targetPath, share),
),
);
} finally {
ShareIntentListener.instance.endFlow();
}
}
void _afterExternalUploaded(