refactor: Improve delete device UX flow
This commit is contained in:
parent
38283d2b27
commit
d14698ee94
3 changed files with 18 additions and 33 deletions
|
|
@ -9,7 +9,6 @@ import 'package:matrix/matrix.dart';
|
|||
|
||||
import 'package:fluffychat/pages/device_settings/device_settings_view.dart';
|
||||
import 'package:fluffychat/pages/key_verification/key_verification_dialog.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
|
||||
class DevicesSettings extends StatefulWidget {
|
||||
|
|
@ -29,9 +28,6 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
|
||||
void reload() => setState(() => devices = null);
|
||||
|
||||
bool loadingDeletingDevices = false;
|
||||
String? errorDeletingDevices;
|
||||
|
||||
bool? chatBackupEnabled;
|
||||
|
||||
@override
|
||||
|
|
@ -69,24 +65,16 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
deviceIds.add(userDevice.deviceId);
|
||||
}
|
||||
|
||||
try {
|
||||
setState(() {
|
||||
loadingDeletingDevices = true;
|
||||
errorDeletingDevices = null;
|
||||
});
|
||||
await matrix.client.uiaRequestBackground(
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.uiaRequestBackground(
|
||||
(auth) => matrix.client.deleteDevices(
|
||||
deviceIds,
|
||||
auth: auth,
|
||||
),
|
||||
);
|
||||
reload();
|
||||
} catch (e, s) {
|
||||
Logs().w('Error while deleting devices', e, s);
|
||||
setState(() => errorDeletingDevices = e.toLocalizedString(context));
|
||||
} finally {
|
||||
setState(() => loadingDeletingDevices = false);
|
||||
}
|
||||
),
|
||||
);
|
||||
reload();
|
||||
}
|
||||
|
||||
void renameDeviceAction(Device device) async {
|
||||
|
|
|
|||
|
|
@ -96,8 +96,7 @@ class DevicesSettingsView extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
child: TextButton.icon(
|
||||
label: Text(
|
||||
controller.errorDeletingDevices ??
|
||||
L10n.of(context).removeAllOtherDevices,
|
||||
L10n.of(context).removeAllOtherDevices,
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor:
|
||||
|
|
@ -105,16 +104,10 @@ class DevicesSettingsView extends StatelessWidget {
|
|||
backgroundColor:
|
||||
theme.colorScheme.errorContainer,
|
||||
),
|
||||
icon: controller.loadingDeletingDevices
|
||||
? const CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
)
|
||||
: const Icon(Icons.delete_outline),
|
||||
onPressed: controller.loadingDeletingDevices
|
||||
? null
|
||||
: () => controller.removeDevicesAction(
|
||||
controller.notThisDevice,
|
||||
),
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
onPressed: () => controller.removeDevicesAction(
|
||||
controller.notThisDevice,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue