App update

This commit is contained in:
Hillel Coren 2020-03-01 21:01:54 +02:00
parent 0fdd44d0bd
commit 86f9d28589
4 changed files with 23 additions and 11 deletions

View File

@ -524,7 +524,7 @@ class SidebarFooterCollapsed extends StatelessWidget {
} }
}, },
itemBuilder: (BuildContext context) => [ itemBuilder: (BuildContext context) => [
if (true || isSelfHosted(context)) if (true || isSelfHosted(context) && kIsWeb)
PopupMenuItem<String>( PopupMenuItem<String>(
child: ListTile( child: ListTile(
leading: Icon( leading: Icon(

View File

@ -7,6 +7,8 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart'; import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
import 'package:invoiceninja_flutter/utils/dialogs.dart'; import 'package:invoiceninja_flutter/utils/dialogs.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/web_stub.dart'
if (dart.library.html) 'package:invoiceninja_flutter/utils/web.dart';
class UpdateDialog extends StatefulWidget { class UpdateDialog extends StatefulWidget {
@override @override
@ -57,15 +59,21 @@ class _UpdateDialogState extends State<UpdateDialog> {
setState(() => _isLoading = true); setState(() => _isLoading = true);
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final credentials = state.credentials; passwordCallback(
final webClient = WebClient(); context: context,
const url = '/self-update'; callback: (password) {
webClient.post(url, credentials.token).then((dynamic response) { final credentials = state.credentials;
print('DONE: $response'); final webClient = WebClient();
setState(() => _isLoading = false); const url = '/self-update';
}).catchError((dynamic error) { webClient
showErrorDialog(context: context, message: '$error'); .post(url, credentials.token, password: password)
setState(() => _isLoading = false); .then((dynamic response) {
}); setState(() => _isLoading = false);
webReload();
}).catchError((dynamic error) {
showErrorDialog(context: context, message: '$error');
setState(() => _isLoading = false);
});
});
} }
} }

View File

@ -25,3 +25,5 @@ void webDownload(String filename, String data) {
..setAttribute('download', filename) ..setAttribute('download', filename)
..click(); ..click();
} }
void webReload() => window.location.reload();

View File

@ -1,3 +1,5 @@
Future<String> webFilePicker() => null; Future<String> webFilePicker() => null;
void webDownload(String filename, String data) {} void webDownload(String filename, String data) {}
void webReload() {}