Consistently send double-check popup
This commit is contained in:
parent
b5a35ad723
commit
a2fde3d70c
5 changed files with 117 additions and 68 deletions
|
|
@ -3724,7 +3724,7 @@
|
|||
},
|
||||
"noTeachersFound": "No teachers found to report to",
|
||||
"pleaseEnterANumber": "Please enter a number greater than 0",
|
||||
"archiveRoomDescription": "The chat will be moved to the archive for all participants.",
|
||||
"archiveRoomDescription": "The chat will be moved to the archive for yourself and all students.",
|
||||
"roomUpgradeDescription": "The chat will then be recreated with the new room version. All participants will be notified that they need to switch to the new chat. You can find out more about room versions at https://spec.matrix.org/latest/rooms/",
|
||||
"removeDevicesDescription": "You will be logged out of this device and will no longer be able to receive messages.",
|
||||
"banUserDescription": "The user will be banned from the chat and will not be able to enter the chat again until they are unbanned.",
|
||||
|
|
@ -3964,5 +3964,7 @@
|
|||
"roomDataMissing": "Some data may be missing from rooms in which you are not a member.",
|
||||
"updatePhoneOS": "You may need to update your device's OS version.",
|
||||
"wordsPerMinute": "Words per minute",
|
||||
"leaveRoomDescription": "The chat will be moved to the archive. Other users will be able to see that you have left the chat."
|
||||
"leaveRoomDescription": "The chat will be moved to the archive. Other users will be able to see that you have left the chat.",
|
||||
"archiveSpaceDescription": "The space, and any chats within, will be moved to the archive for yourself and all students.",
|
||||
"leaveSpaceDescription": "The space, and any chats within, will be moved to the archive. Other users will be able to see that you have left the space."
|
||||
}
|
||||
|
|
@ -542,28 +542,39 @@ class ChatDetailsView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message:
|
||||
L10n.of(context)!.archiveRoomDescription,
|
||||
);
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
OkCancelResult confirmed = OkCancelResult.ok;
|
||||
// archiveSpace has its own popup; only show if not space
|
||||
if (!room.isSpace) {
|
||||
confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
future: () async {
|
||||
room.isSpace
|
||||
? await room.archiveSpace(
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await room.archive();
|
||||
},
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!
|
||||
.archiveRoomDescription,
|
||||
);
|
||||
if (success.error == null) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
if (room.isSpace) {
|
||||
final archived = await room.archiveSpace(
|
||||
context,
|
||||
Matrix.of(context).client,
|
||||
);
|
||||
if (archived) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
} else {
|
||||
final success =
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
await room.archive();
|
||||
},
|
||||
);
|
||||
if (success.error == null) {
|
||||
context.go('/rooms');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -585,20 +596,25 @@ class ChatDetailsView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!.leaveRoomDescription,
|
||||
);
|
||||
OkCancelResult confirmed = OkCancelResult.ok;
|
||||
// leaveSpace has its own popup; only show if not space
|
||||
if (!room.isSpace) {
|
||||
confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!.leaveRoomDescription,
|
||||
);
|
||||
}
|
||||
if (confirmed == OkCancelResult.ok) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
room.isSpace
|
||||
? await room.leaveSpace(
|
||||
context,
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await room.leave();
|
||||
|
|
|
|||
|
|
@ -186,13 +186,6 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||
tooltip: L10n.of(context)!.archive,
|
||||
onPressed: controller.archiveAction,
|
||||
),
|
||||
// #Pangea
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
tooltip: L10n.of(context)!.leave,
|
||||
onPressed: controller.leaveAction,
|
||||
),
|
||||
// Pangea#
|
||||
]
|
||||
: null,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -284,17 +284,13 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
case SpaceChildContextAction.leave:
|
||||
// #Pangea
|
||||
widget.controller.cancelAction();
|
||||
widget.controller.selectedRoomIds.clear();
|
||||
if (room == null) return;
|
||||
widget.controller.toggleSelection(room.id);
|
||||
room.isSpace
|
||||
? await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
await room.leaveSpace(
|
||||
Matrix.of(context).client,
|
||||
);
|
||||
widget.controller.selectedRoomIds.clear();
|
||||
},
|
||||
? await room.leaveSpace(
|
||||
context,
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await widget.controller.leaveAction();
|
||||
_refresh();
|
||||
|
|
@ -315,20 +311,28 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
case SpaceChildContextAction.archive:
|
||||
widget.controller.cancelAction();
|
||||
// #Pangea
|
||||
widget.controller.selectedRoomIds.clear();
|
||||
if (room == null) return;
|
||||
// Pangea#
|
||||
widget.controller.toggleSelection(room.id);
|
||||
room.isSpace
|
||||
? await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
await room.archiveSpace(
|
||||
Matrix.of(context).client,
|
||||
);
|
||||
widget.controller.selectedRoomIds.clear();
|
||||
},
|
||||
// #Pangea
|
||||
// ? await showFutureLoadingDialog(
|
||||
// context: context,
|
||||
// future: () async {
|
||||
// await room.archiveSpace(
|
||||
// Matrix.of(context).client,
|
||||
// );
|
||||
// widget.controller.selectedRoomIds.clear();
|
||||
// },
|
||||
// )
|
||||
// : await widget.controller.archiveAction();
|
||||
? await room.archiveSpace(
|
||||
context,
|
||||
Matrix.of(context).client,
|
||||
)
|
||||
: await widget.controller.archiveAction();
|
||||
// Pangea#
|
||||
_refresh();
|
||||
break;
|
||||
case SpaceChildContextAction.addToSpace:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
|
|
@ -13,6 +14,8 @@ import 'package:fluffychat/pangea/utils/bot_name.dart';
|
|||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
// import markdown.dart
|
||||
import 'package:html_unescape/html_unescape.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -826,23 +829,54 @@ extension PangeaRoom on Room {
|
|||
await leave();
|
||||
}
|
||||
|
||||
Future<void> archiveSpace(Client client) async {
|
||||
final List<Room> children = await getChildRooms();
|
||||
for (final Room child in children) {
|
||||
await child.archive();
|
||||
}
|
||||
await archive();
|
||||
Future<bool> archiveSpace(BuildContext context, Client client) async {
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.yes,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!.archiveSpaceDescription,
|
||||
) ==
|
||||
OkCancelResult.ok;
|
||||
if (!confirmed) return false;
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
final List<Room> children = await getChildRooms();
|
||||
for (final Room child in children) {
|
||||
await child.archive();
|
||||
}
|
||||
await archive();
|
||||
},
|
||||
);
|
||||
return success.error == null;
|
||||
}
|
||||
|
||||
Future<void> leaveSpace(Client client) async {
|
||||
final List<Room> children = await getChildRooms();
|
||||
for (final Room child in children) {
|
||||
if (child.isUnread) {
|
||||
await child.markUnread(false);
|
||||
}
|
||||
await child.leave();
|
||||
}
|
||||
await leave();
|
||||
Future<void> leaveSpace(BuildContext context, Client client) async {
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.yes,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
message: L10n.of(context)!.leaveSpaceDescription,
|
||||
) ==
|
||||
OkCancelResult.ok;
|
||||
if (!confirmed) return;
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
final List<Room> children = await getChildRooms();
|
||||
for (final Room child in children) {
|
||||
if (child.isUnread) {
|
||||
await child.markUnread(false);
|
||||
}
|
||||
await child.leave();
|
||||
}
|
||||
await leave();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
bool canIAddSpaceChild(Room? room) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue