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(
tooltip: localization!.enableReactApp,
onPressed: () async {
final credentials = state.credentials;
final account = state.account
.rebuild((b) => b..setReactAsDefaultAP = true);
final url = '${credentials.url}/accounts/${account.id}';
final data = serializers.serializeWith(
AccountEntity.serializer, account);
confirmCallback(
context: context,
message: localization.enableReactApp,
callback: (_) {
final credentials = state.credentials;
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());
WebClient()
.put(
url,
credentials.token,
data: json.encode(data),
)
.then((dynamic _) {
store.dispatch(StopSaving());
WebUtils.reloadBrowser();
}).catchError((Object error) {
store.dispatch(StopSaving());
showErrorDialog(message: error as String?);
});
store.dispatch(StartSaving());
WebClient()
.put(
url,
credentials.token,
data: json.encode(data),
)
.then((dynamic _) {
store.dispatch(StopSaving());
WebUtils.reloadBrowser();
}).catchError((Object error) {
store.dispatch(StopSaving());
showErrorDialog(message: error as String?);
});
});
},
icon: Icon(MdiIcons.react),
),