diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index e3ff06b16..ba07fea9f 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4041,14 +4041,38 @@ "tooltipInstructionsMobileBody": "Press and hold items to view tooltips.", "tooltipInstructionsBrowserBody": "Hover over items to view tooltips.", "addSpaceToSpaceDescription": "Select a space to add as a parent", - "roomCapacity": "Room Capacity", + "roomCapacity": "{roomType} Capacity", + "@roomCapacity": { + "type": "text", + "placeholders": { + "roomType": {} + } + }, "roomFull": "This room is already at capacity.", "topicNotSet": "The topic has not been set.", "capacityNotSet": "This room has no capacity limit.", - "roomCapacityHasBeenChanged": "Room capacity changed", + "roomCapacityHasBeenChanged": "{roomType} capacity changed", + "@roomCapacityHasBeenChanged": { + "type": "text", + "placeholders": { + "roomType": {} + } + }, "roomExceedsCapacity": "Room exceeds capacity. Consider removing students from the room, or raising the capacity.", - "capacitySetTooLow": "Room capacity cannot be set below the current number of non-admins.", - "roomCapacityExplanation": "Room capacity limits the number of non-admins allowed in a room.", + "capacitySetTooLow": "{roomType} capacity cannot be set below the current number of non-admins.", + "@capacitySetTooLow": { + "type": "text", + "placeholders": { + "roomType": {} + } + }, + "roomCapacityExplanation": "{roomType} capacity limits the number of non-admins allowed in a room.", + "@roomCapacityExplanation": { + "type": "text", + "placeholders": { + "roomType": {} + } + }, "enterNumber": "Please enter a whole number value.", "buildTranslation": "Build your translation from the choices above", "noDatabaseEncryption": "Database encryption is not supported on this platform", @@ -4129,5 +4153,6 @@ "error520Title": "Please try again.", "error520Desc": "Sorry, we could not understand your message...", "translationChoicesBody": "Click and hold an option for a hint.", - "sendCanceled": "Sending canceled" + "sendCanceled": "Sending canceled", + "space": "Space" } \ No newline at end of file diff --git a/lib/pages/new_space/new_space_view.dart b/lib/pages/new_space/new_space_view.dart index 9ef9c9849..7996def21 100644 --- a/lib/pages/new_space/new_space_view.dart +++ b/lib/pages/new_space/new_space_view.dart @@ -115,6 +115,7 @@ class NewSpaceView extends StatelessWidget { RoomCapacityButton( key: controller.addCapacityKey, + spaceMode: true, ), // commenting out language settings in spaces for now // LanguageSettings( diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index cd4ce5e76..06462cbea 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -477,28 +477,10 @@ class PangeaMessageEvent { return representationByLanguage(langCode)?.text ?? body; } - bool get isNew => - DateTime.now().difference(originServerTs.toLocal()).inSeconds < 8; - - Future _repLocal(String langCode) async { - int tries = 0; - - RepresentationEvent? rep = representationByLanguage(langCode); - - while ((isNew || eventId.contains("web")) && tries < 20) { - if (rep != null) return rep; - await Future.delayed(const Duration(milliseconds: 500)); - rep = representationByLanguage(langCode); - tries += 1; - } - return rep; - } - Future representationByLanguageGlobal({ required String langCode, }) async { - // try { - final RepresentationEvent? repLocal = await _repLocal(langCode); + final RepresentationEvent? repLocal = representationByLanguage(langCode); if (repLocal != null || langCode == LanguageKeys.unknownLanguage || @@ -519,11 +501,7 @@ class PangeaMessageEvent { target: langCode, room: _latestEdit.room, ); - - if (pangeaRep == null || - await _latestEdit.room.getEventById(_latestEdit.eventId) == null) { - return null; - } + if (pangeaRep == null) return null; MatrixState.pangeaController.messageData .sendRepresentationMatrixEvent( diff --git a/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button.dart b/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button.dart index 7be6e8ec3..11452830c 100644 --- a/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button.dart +++ b/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button.dart @@ -9,10 +9,13 @@ import 'package:matrix/matrix.dart'; class RoomCapacityButton extends StatefulWidget { final Room? room; final ChatDetailsController? controller; + final bool spaceMode; + const RoomCapacityButton({ super.key, this.room, this.controller, + this.spaceMode = false, }); @override @@ -66,6 +69,15 @@ class RoomCapacityButtonState extends State { } } + String get roomType { + final String chat = L10n.of(context)!.chat; + final String space = L10n.of(context)!.space; + if (widget.room != null) { + return widget.room!.isSpace ? space : chat; + } + return widget.spaceMode ? space : chat; + } + @override Widget build(BuildContext context) { final iconColor = Theme.of(context).textTheme.bodyLarge!.color; @@ -86,7 +98,7 @@ class RoomCapacityButtonState extends State { : '$capacity', ), title: Text( - L10n.of(context)!.roomCapacity, + L10n.of(context)!.roomCapacity(roomType), style: TextStyle( color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, @@ -104,8 +116,8 @@ class RoomCapacityButtonState extends State { Future setRoomCapacity() async { final input = await showTextInputDialog( context: context, - title: L10n.of(context)!.roomCapacity, - message: L10n.of(context)!.roomCapacityExplanation, + title: L10n.of(context)!.roomCapacity(roomType), + message: L10n.of(context)!.roomCapacityExplanation(roomType), okLabel: L10n.of(context)!.ok, cancelLabel: L10n.of(context)!.cancel, textFields: [ @@ -121,7 +133,7 @@ class RoomCapacityButtonState extends State { return L10n.of(context)!.enterNumber; } if (nonAdmins != null && int.parse(value) < int.parse(nonAdmins!)) { - return L10n.of(context)!.capacitySetTooLow; + return L10n.of(context)!.capacitySetTooLow(roomType); } return null; }, @@ -147,7 +159,7 @@ class RoomCapacityButtonState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - L10n.of(context)!.roomCapacityHasBeenChanged, + L10n.of(context)!.roomCapacityHasBeenChanged(roomType), ), ), ); diff --git a/lib/pangea/widgets/chat/message_translation_card.dart b/lib/pangea/widgets/chat/message_translation_card.dart index 278c7d7ed..bcf837c0e 100644 --- a/lib/pangea/widgets/chat/message_translation_card.dart +++ b/lib/pangea/widgets/chat/message_translation_card.dart @@ -33,7 +33,7 @@ class MessageTranslationCardState extends State { String? oldSelectedText; bool _fetchingRepresentation = false; - Future fetchRepresentation(BuildContext context) async { + Future fetchRepresentation() async { if (l1Code == null) return; repEvent = widget.messageEvent @@ -102,15 +102,13 @@ class MessageTranslationCardState extends State { @override void initState() { super.initState(); - if (mounted) { - setState(() {}); - } - loadTranslation(() async { + final List futures = []; + futures.add(fetchRepresentation()); if (widget.selection.selectedText != null) { - await translateSelection(); + futures.add(translateSelection()); } - await fetchRepresentation(context); + await Future.wait(futures); }); }