dialog qr si chiude quando upload finito
This commit is contained in:
@@ -507,12 +507,17 @@ class _SharedAttachmentsSectionState extends State<SharedAttachmentsSection> {
|
||||
'https://flux.catelli.it/upload/${state.parentType.name}/$targetId?companyId=$companyId';
|
||||
|
||||
if (context.mounted) {
|
||||
final attachmentBloc = context.read<AttachmentsBloc>();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => QrUploadDialog(
|
||||
builder: (_) => BlocProvider.value(
|
||||
value: attachmentBloc,
|
||||
child: QrUploadDialog(
|
||||
deepLinkUrl: deepLink,
|
||||
title: 'Carica File: ${widget.titleForUpload}',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -82,7 +82,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
}
|
||||
}
|
||||
|
||||
emit(state.copyWith(localFiles: [], status: AttachmentsStatus.success));
|
||||
emit(state.copyWith(localFiles: [], status: AttachmentsStatus.ready));
|
||||
add(LoadAttachmentsEvent(parentId: event.newParentId));
|
||||
}
|
||||
|
||||
@@ -100,10 +100,8 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
currentId,
|
||||
state.parentType,
|
||||
), // Passiamo il tipo!
|
||||
onData: (List<AttachmentModel> data) => state.copyWith(
|
||||
status: AttachmentsStatus.success,
|
||||
remoteFiles: data,
|
||||
),
|
||||
onData: (List<AttachmentModel> data) =>
|
||||
state.copyWith(status: AttachmentsStatus.ready, remoteFiles: data),
|
||||
onError: (error, stackTrace) => state.copyWith(
|
||||
status: AttachmentsStatus.failure,
|
||||
error: error.toString(),
|
||||
@@ -143,7 +141,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
emit(
|
||||
state.copyWith(
|
||||
localFiles: [...state.localFiles, ...newLocalFiles],
|
||||
status: AttachmentsStatus.success,
|
||||
status: AttachmentsStatus.ready,
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -162,7 +160,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
}).toList();
|
||||
|
||||
await Future.wait(uploadTasks);
|
||||
emit(state.copyWith(status: AttachmentsStatus.success));
|
||||
emit(state.copyWith(status: AttachmentsStatus.ready));
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(status: AttachmentsStatus.failure, error: e.toString()),
|
||||
@@ -245,9 +243,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
files: state.selectedFiles,
|
||||
currentContextType: state.parentType,
|
||||
);
|
||||
emit(
|
||||
state.copyWith(status: AttachmentsStatus.success, selectedFiles: []),
|
||||
);
|
||||
emit(state.copyWith(status: AttachmentsStatus.ready, selectedFiles: []));
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(status: AttachmentsStatus.failure, error: e.toString()),
|
||||
@@ -311,7 +307,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
state.copyWith(
|
||||
localFiles: updatedLocalFiles,
|
||||
selectedFiles: [], // Svuotiamo la selezione
|
||||
status: AttachmentsStatus.success,
|
||||
status: AttachmentsStatus.ready,
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -337,9 +333,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
await Future.wait(linkTasks);
|
||||
|
||||
// Lo stream aggiornerà automaticamente la UI
|
||||
emit(
|
||||
state.copyWith(status: AttachmentsStatus.success, selectedFiles: []),
|
||||
);
|
||||
emit(state.copyWith(status: AttachmentsStatus.ready, selectedFiles: []));
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
@@ -370,7 +364,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
emit(state.copyWith(status: AttachmentsStatus.loading));
|
||||
try {
|
||||
await _repository.renameAttachment(event.file.id!, event.newName);
|
||||
emit(state.copyWith(status: AttachmentsStatus.success));
|
||||
emit(state.copyWith(status: AttachmentsStatus.ready));
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
part of 'attachments_bloc.dart';
|
||||
|
||||
enum AttachmentsStatus { initial, loading, uploading, success, failure }
|
||||
enum AttachmentsStatus { initial, loading, ready, uploading, success, failure }
|
||||
|
||||
enum AttachmentParentType {
|
||||
operation('operation_id'),
|
||||
|
||||
Reference in New Issue
Block a user