workaround for reactions not updating on historical timeline

This commit is contained in:
Henry Hiles 2026-09-28 11:03:55 -04:00
commit 5304f22456
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 27 additions and 25 deletions

View file

@ -27,17 +27,14 @@ extension BuildEventOptions on Event {
final theme = Theme.of(context); final theme = Theme.of(context);
final danger = theme.colorScheme.error; final danger = theme.colorScheme.error;
final notifier = ref.read( final notifier = RoomChatController.provider((roomId, null)).notifier;
RoomChatController.provider((roomId, null)).notifier,
);
final client = ref.read(ClientController.provider.notifier);
final isPinned = ref final isPinned = ref
.watch(PinnedIdsController.provider(roomId)) .watch(PinnedIdsController.provider(roomId))
.contains(eventId); .contains(eventId);
Future<void> sendReaction(String emoji) async { Future<void> sendReaction(String emoji) async {
await notifier.sendReaction(emoji, this).onError(showError); await ref.watch(notifier).sendReaction(emoji, this).onError(showError);
await ref await ref
.read(RecentEmojiController.provider.notifier) .read(RecentEmojiController.provider.notifier)
@ -233,7 +230,8 @@ extension BuildEventOptions on Event {
"Are you sure you want to delete this message? " "Are you sure you want to delete this message? "
"This cannot be reversed.", "This cannot be reversed.",
action: "Delete", action: "Delete",
onConfirm: (reason) => notifier.deleteMessage(this, reason: reason), onConfirm: (reason) =>
ref.watch(notifier).deleteMessage(this, reason: reason),
), ),
child: ListTile( child: ListTile(
leading: Icon(Icons.delete, color: danger), leading: Icon(Icons.delete, color: danger),
@ -248,7 +246,9 @@ extension BuildEventOptions on Event {
"Report this this to your server administrators, " "Report this this to your server administrators, "
"who can take action like banning this server or room.", "who can take action like banning this server or room.",
action: "Report", action: "Report",
onConfirm: (reason) => client.reportEvent( onConfirm: (reason) => ref
.read(ClientController.provider.notifier)
.reportEvent(
.new( .new(
roomId: roomId, roomId: roomId,
eventId: eventId, eventId: eventId,

View file

@ -8,7 +8,6 @@ import "package:nexus/helpers/mxc_image.dart";
import "package:nexus/models/event.dart"; import "package:nexus/models/event.dart";
import "package:nexus/widgets/error_dialog.dart"; import "package:nexus/widgets/error_dialog.dart";
import "package:nexus/main.dart"; import "package:nexus/main.dart";
import "package:fast_immutable_collections/fast_immutable_collections.dart";
class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget { class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget {
@override @override
@ -22,22 +21,20 @@ class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget {
.new(roomId: event.roomId, eventRowId: event.rowId), .new(roomId: event.roomId, eventRowId: event.rowId),
), ),
)) { )) {
AsyncData(value: final IMap<String, IList<String>>? reactors) || AsyncData(value: final reactions) ||
AsyncLoading(value: final reactors) => Wrap( AsyncLoading(value: final reactions?) => Wrap(
spacing: 4, spacing: 4,
runSpacing: 4, runSpacing: 4,
children: event.reactions children: reactions
.where((_, value) => value != 0) .where((_, value) => value.isNotEmpty)
.mapTo( .mapTo(
(reaction, count) => HookBuilder( (reaction, reactors) => HookBuilder(
builder: (context) { builder: (context) {
final enabled = useState(true); final enabled = useState(true);
final selected = final selected = reactors.contains(clientState!.userId);
reactors?[reaction]?.contains(clientState!.userId) ??
false;
return Tooltip( return Tooltip(
message: reactors?[reaction]?.join(", ") ?? "", message: reactors.join(", "),
child: ChoiceChip( child: ChoiceChip(
showCheckmark: false, showCheckmark: false,
selected: selected, selected: selected,
@ -56,7 +53,10 @@ class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget {
) )
: Text(reaction, overflow: .ellipsis), : Text(reaction, overflow: .ellipsis),
), ),
Text(count.toString(), overflow: .ellipsis), Text(
reactors.length.toString(),
overflow: .ellipsis,
),
], ],
), ),
onSelected: enabled.value onSelected: enabled.value
@ -75,7 +75,7 @@ class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget {
.removeReaction( .removeReaction(
reaction, reaction,
event, event,
clientState!.userId!, clientState.userId!,
) )
.onError(showError); .onError(showError);
} else { } else {
@ -100,6 +100,8 @@ class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget {
error, error,
stackTrace, stackTrace,
), ),
_ => SizedBox.shrink(),
}, },
); );
} }