Show progress while printing

This commit is contained in:
Hillel Coren 2022-05-27 11:53:00 +03:00
parent dc8c153f19
commit 225742d92a
4 changed files with 17 additions and 12 deletions

View File

@ -633,10 +633,10 @@ Future handleCreditAction(
case EntityAction.printPdf:
final invitation = credit.invitations.first;
final url = invitation.downloadLink;
store.dispatch(StartLoading());
store.dispatch(StartSaving());
final http.Response response =
await WebClient().get(url, '', rawResponse: true);
store.dispatch(StopLoading());
store.dispatch(StopSaving());
await Printing.layoutPdf(onLayout: (_) => response.bodyBytes);
break;
case EntityAction.more:

View File

@ -700,10 +700,10 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
case EntityAction.printPdf:
final invitation = invoice.invitations.first;
final url = invitation.downloadLink;
store.dispatch(StartLoading());
store.dispatch(StartSaving());
final http.Response response =
await WebClient().get(url, '', rawResponse: true);
store.dispatch(StopLoading());
store.dispatch(StopSaving());
await Printing.layoutPdf(onLayout: (_) => response.bodyBytes);
break;
case EntityAction.more:

View File

@ -652,10 +652,10 @@ Future handleQuoteAction(
case EntityAction.printPdf:
final invitation = quote.invitations.first;
final url = invitation.downloadLink;
store.dispatch(StartLoading());
store.dispatch(StartSaving());
final http.Response response =
await WebClient().get(url, '', rawResponse: true);
store.dispatch(StopLoading());
store.dispatch(StopSaving());
await Printing.layoutPdf(onLayout: (_) => response.bodyBytes);
break;
case EntityAction.more:

View File

@ -73,13 +73,18 @@ class TemplatesAndRemindersVM {
return;
}
final url = '${state.credentials.url}/invoices/update_reminders';
store.dispatch(StartLoading());
await WebClient().post(url, state.credentials.token);
store.dispatch(StartSaving());
WebClient()
.post(url, state.credentials.token)
.then((dynamic value) {
// Give the server a few seconds to process
Timer(Duration(seconds: 2), () {
store.dispatch(StopLoading());
store.dispatch(StopSaving());
store.dispatch(RefreshData());
});
}).catchError((dynamic error) {
store.dispatch(StopSaving());
});
};
final settingsUIState = store.state.uiState.settingsUIState;