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

View file

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