feat: end polls
This commit is contained in:
parent
c9cf4e90bf
commit
7bac9f8a85
|
|
@ -6,6 +6,7 @@
|
||||||
"longPressToRecordVoiceMessage": "Long press to record voice message.",
|
"longPressToRecordVoiceMessage": "Long press to record voice message.",
|
||||||
"pause": "Pause",
|
"pause": "Pause",
|
||||||
"resume": "Resume",
|
"resume": "Resume",
|
||||||
|
"endPoll": "End poll",
|
||||||
"anonymousPoll": "Anonymous",
|
"anonymousPoll": "Anonymous",
|
||||||
"publicPoll": "Public",
|
"publicPoll": "Public",
|
||||||
"endedPoll": "Ended",
|
"endedPoll": "Ended",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
"pleaseEnterQuestion": "Введите вопрос",
|
"pleaseEnterQuestion": "Введите вопрос",
|
||||||
"atLeastTwoAnswersRequired": "Требуется хотя бы 2 ответа",
|
"atLeastTwoAnswersRequired": "Требуется хотя бы 2 ответа",
|
||||||
"maxSelections": "Количество ответов",
|
"maxSelections": "Количество ответов",
|
||||||
|
"endPoll": "Завершить опрос",
|
||||||
"createPoll": "Создать опрос",
|
"createPoll": "Создать опрос",
|
||||||
"alwaysUse24HourFormat": "нет",
|
"alwaysUse24HourFormat": "нет",
|
||||||
"@alwaysUse24HourFormat": {
|
"@alwaysUse24HourFormat": {
|
||||||
|
|
|
||||||
|
|
@ -551,8 +551,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
void sendPollAction() async {
|
void sendPollAction() async {
|
||||||
await showAdaptiveDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) => SendPollDialog(room: room, outerContext: context)
|
builder: (c) => SendPollDialog(room: room, outerContext: context));
|
||||||
);
|
|
||||||
replyEvent = null;
|
replyEvent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -872,6 +871,22 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void endPollAction() async {
|
||||||
|
final event = selectedEvents.first;
|
||||||
|
if (event == null) return;
|
||||||
|
final client = currentRoomBundle.firstWhere(
|
||||||
|
(cl) => selectedEvents.first.senderId == cl!.userID,
|
||||||
|
orElse: () => null,
|
||||||
|
);
|
||||||
|
if (client == null) return;
|
||||||
|
if (event.senderId != client!.userID) return;
|
||||||
|
await room.sendEvent({
|
||||||
|
'org.matrix.msc1767.text': 'Ended poll',
|
||||||
|
'm.relates_to': {'rel_type': 'm.reference', 'event_id': event.eventId},
|
||||||
|
'body': 'Ended poll'
|
||||||
|
}, type: 'org.matrix.msc3381.poll.end');
|
||||||
|
}
|
||||||
|
|
||||||
void redactEventsAction() async {
|
void redactEventsAction() async {
|
||||||
final reasonInput = selectedEvents.any((event) => event.status.isSent)
|
final reasonInput = selectedEvents.any((event) => event.status.isSent)
|
||||||
? await showTextInputDialog(
|
? await showTextInputDialog(
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import '../../utils/stream_extension.dart';
|
||||||
import 'chat_emoji_picker.dart';
|
import 'chat_emoji_picker.dart';
|
||||||
import 'chat_input_row.dart';
|
import 'chat_input_row.dart';
|
||||||
|
|
||||||
enum _EventContextAction { info, recover, translate, report }
|
enum _EventContextAction { info, recover, translate, report, endPoll }
|
||||||
|
|
||||||
class ChatView extends StatelessWidget {
|
class ChatView extends StatelessWidget {
|
||||||
final ChatController controller;
|
final ChatController controller;
|
||||||
|
|
@ -92,6 +92,9 @@ class ChatView extends StatelessWidget {
|
||||||
case _EventContextAction.translate:
|
case _EventContextAction.translate:
|
||||||
controller.translateEventAction();
|
controller.translateEventAction();
|
||||||
break;
|
break;
|
||||||
|
case _EventContextAction.endPoll:
|
||||||
|
controller.endPollAction();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
itemBuilder: (context) => [
|
itemBuilder: (context) => [
|
||||||
|
|
@ -115,6 +118,21 @@ class ChatView extends StatelessWidget {
|
||||||
Text(L10n.of(context).recoverMessage),
|
Text(L10n.of(context).recoverMessage),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
if (controller.selectedEvents.single.type == 'org.matrix.msc3381.poll.start' && controller.selectedEvents.single.senderId == Matrix.of(context).client.userID)
|
||||||
|
|
||||||
|
PopupMenuItem(
|
||||||
|
value: _EventContextAction.endPoll,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.check,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(L10n.of(context).endPoll),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
if (controller.selectedEvents.single.status.isSent)
|
if (controller.selectedEvents.single.status.isSent)
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: _EventContextAction.report,
|
value: _EventContextAction.report,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue