Add confirmation when switching to the React app

This commit is contained in:
Hillel Coren 2023-11-16 13:12:47 +02:00
parent 1e685cb5c4
commit 7252bf81b5
1 changed files with 25 additions and 20 deletions

View File

@ -267,27 +267,32 @@ class _DashboardScreenState extends State<DashboardScreen>
child: IconButton( child: IconButton(
tooltip: localization!.enableReactApp, tooltip: localization!.enableReactApp,
onPressed: () async { onPressed: () async {
final credentials = state.credentials; confirmCallback(
final account = state.account context: context,
.rebuild((b) => b..setReactAsDefaultAP = true); message: localization.enableReactApp,
final url = '${credentials.url}/accounts/${account.id}'; callback: (_) {
final data = serializers.serializeWith( final credentials = state.credentials;
AccountEntity.serializer, account); final account = state.account
.rebuild((b) => b..setReactAsDefaultAP = true);
final url = '${credentials.url}/accounts/${account.id}';
final data = serializers.serializeWith(
AccountEntity.serializer, account);
store.dispatch(StartSaving()); store.dispatch(StartSaving());
WebClient() WebClient()
.put( .put(
url, url,
credentials.token, credentials.token,
data: json.encode(data), data: json.encode(data),
) )
.then((dynamic _) { .then((dynamic _) {
store.dispatch(StopSaving()); store.dispatch(StopSaving());
WebUtils.reloadBrowser(); WebUtils.reloadBrowser();
}).catchError((Object error) { }).catchError((Object error) {
store.dispatch(StopSaving()); store.dispatch(StopSaving());
showErrorDialog(message: error as String?); showErrorDialog(message: error as String?);
}); });
});
}, },
icon: Icon(MdiIcons.react), icon: Icon(MdiIcons.react),
), ),