mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-18 10:52:34 +01:00
feat: Send reactions to multiple events
This commit is contained in:
parent
068e312726
commit
f4425771f8
@ -631,14 +631,14 @@ class ChatController extends State<Chat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendEmojiAction(String emoji) async {
|
void sendEmojiAction(String emoji) async {
|
||||||
await showFutureLoadingDialog(
|
final events = List<Event>.from(selectedEvents);
|
||||||
context: context,
|
|
||||||
future: () => room.sendReaction(
|
|
||||||
selectedEvents.single.eventId,
|
|
||||||
emoji,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
setState(() => selectedEvents.clear());
|
setState(() => selectedEvents.clear());
|
||||||
|
for (final event in events) {
|
||||||
|
await room.sendReaction(
|
||||||
|
event.eventId,
|
||||||
|
emoji,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearSelectedEvents() => setState(() {
|
void clearSelectedEvents() => setState(() {
|
||||||
|
@ -41,44 +41,53 @@ class MessageReactions extends StatelessWidget {
|
|||||||
reactionMap[key].reacted |= e.senderId == e.room.client.userID;
|
reactionMap[key].reacted |= e.senderId == e.room.client.userID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final reactionList = reactionMap.values.toList();
|
final reactionList = reactionMap.values.toList();
|
||||||
reactionList.sort((a, b) => b.count - a.count > 0 ? 1 : -1);
|
reactionList.sort((a, b) => b.count - a.count > 0 ? 1 : -1);
|
||||||
return Wrap(
|
return Wrap(spacing: 4.0, runSpacing: 4.0, children: [
|
||||||
spacing: 4.0,
|
if (allReactionEvents.any((e) => e.status.isSending))
|
||||||
runSpacing: 4.0,
|
const SizedBox(
|
||||||
children: reactionList
|
width: 28,
|
||||||
.map(
|
height: 28,
|
||||||
(r) => _Reaction(
|
child: Padding(
|
||||||
reactionKey: r.key,
|
padding: EdgeInsets.all(4.0),
|
||||||
count: r.count,
|
child: CircularProgressIndicator.adaptive(strokeWidth: 1),
|
||||||
reacted: r.reacted,
|
),
|
||||||
onTap: () {
|
),
|
||||||
if (r.reacted) {
|
...reactionList
|
||||||
final evt = allReactionEvents.firstWhere(
|
.map(
|
||||||
(e) =>
|
(r) => _Reaction(
|
||||||
e.senderId == e.room.client.userID &&
|
reactionKey: r.key,
|
||||||
e.content['m.relates_to']['key'] == r.key,
|
count: r.count,
|
||||||
orElse: () => null);
|
reacted: r.reacted,
|
||||||
if (evt != null) {
|
onTap: () {
|
||||||
showFutureLoadingDialog(
|
if (r.reacted) {
|
||||||
context: context,
|
final evt = allReactionEvents.firstWhere(
|
||||||
future: () => evt.redactEvent(),
|
(e) =>
|
||||||
);
|
e.senderId == e.room.client.userID &&
|
||||||
}
|
e.content['m.relates_to']['key'] == r.key,
|
||||||
} else {
|
orElse: () => null);
|
||||||
|
if (evt != null) {
|
||||||
showFutureLoadingDialog(
|
showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () =>
|
future: () => evt.redactEvent(),
|
||||||
event.room.sendReaction(event.eventId, r.key));
|
);
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
onLongPress: () async => await _AdaptableReactorsDialog(
|
showFutureLoadingDialog(
|
||||||
client: client,
|
context: context,
|
||||||
reactionEntry: r,
|
future: () =>
|
||||||
).show(context),
|
event.room.sendReaction(event.eventId, r.key));
|
||||||
),
|
}
|
||||||
)
|
},
|
||||||
.toList());
|
onLongPress: () async => await _AdaptableReactorsDialog(
|
||||||
|
client: client,
|
||||||
|
reactionEntry: r,
|
||||||
|
).show(context),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,20 +12,17 @@ class ReactionsPicker extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (controller.showEmojiPicker) return Container();
|
if (controller.showEmojiPicker) return Container();
|
||||||
|
final display = controller.editEvent == null &&
|
||||||
|
controller.replyEvent == null &&
|
||||||
|
controller.room.canSendDefaultMessages &&
|
||||||
|
controller.selectedEvents.isNotEmpty;
|
||||||
return AnimatedContainer(
|
return AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
height: (controller.editEvent == null &&
|
height: (display) ? 56 : 0,
|
||||||
controller.replyEvent == null &&
|
|
||||||
controller.room.canSendDefaultMessages &&
|
|
||||||
controller.selectedEvents.length == 1)
|
|
||||||
? 56
|
|
||||||
: 0,
|
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Theme.of(context).secondaryHeaderColor,
|
color: Theme.of(context).secondaryHeaderColor,
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
if (!(controller.editEvent == null &&
|
if (!display) {
|
||||||
controller.replyEvent == null &&
|
|
||||||
controller.selectedEvents.length == 1)) {
|
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
final emojis = List<String>.from(AppEmojis.emojis);
|
final emojis = List<String>.from(AppEmojis.emojis);
|
||||||
|
Loading…
Reference in New Issue
Block a user