forked from Nexus/nexus
support a lot more events to be rendered
Also adds show hidden events setting. Fixes #178
This commit is contained in:
parent
3cf0b811bb
commit
6e6bcaaad1
1 changed files with 233 additions and 87 deletions
|
|
@ -1,13 +1,8 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/controllers/event.dart";
|
||||
import "package:nexus/controllers/rooms.dart";
|
||||
import "package:nexus/helpers/hooks/chat_scroll.dart";
|
||||
import "package:nexus/helpers/extensions/success_scheme.dart";
|
||||
import "package:nexus/models/content/message.dart";
|
||||
import "package:nexus/widgets/lazy_loading/message_displayname.dart";
|
||||
import "package:nexus/widgets/renderers/event.dart";
|
||||
import "package:nexus/widgets/renderers/related_event_line.dart";
|
||||
|
||||
/// A line for each message a pinned events event pinned, in green, and each one
|
||||
/// it unpinned, in red and struck through.
|
||||
|
|
@ -19,11 +14,11 @@ class const PinnedEventsDiff(
|
|||
/// If set, tapping a message jumps to it.
|
||||
final JumpToEvent? jumpToEvent,
|
||||
super.key,
|
||||
}) extends ConsumerWidget {
|
||||
}) extends StatelessWidget {
|
||||
static const maxShown = 5;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final style = theme.textTheme.labelMedium;
|
||||
final changes = [
|
||||
|
|
@ -43,66 +38,12 @@ class const PinnedEventsDiff(
|
|||
? TextDecoration.lineThrough
|
||||
: null;
|
||||
|
||||
return DefaultTextStyle.merge(
|
||||
style: style?.copyWith(
|
||||
color: color,
|
||||
decoration: decoration,
|
||||
decorationColor: color,
|
||||
),
|
||||
child: switch (ref.watch(
|
||||
EventController.provider(
|
||||
.new(roomId: roomId, eventId: change.$1),
|
||||
),
|
||||
)) {
|
||||
// Keeps showing the event while it reloads
|
||||
AsyncValue(value: final rowId?) => InkWell(
|
||||
borderRadius: .circular(4),
|
||||
hoverColor: color.withValues(alpha: 0.12),
|
||||
onTap: jumpToEvent == null ? null : () => jumpToEvent!(rowId),
|
||||
child: Row(
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
// Other events already say who sent them
|
||||
if (ref.watch(
|
||||
RoomsController.provider.select(
|
||||
(rooms) => rooms[roomId]?.events[rowId],
|
||||
),
|
||||
)
|
||||
case final event?
|
||||
when event.content is MessageContent) ...[
|
||||
MessageDisplayname(
|
||||
event,
|
||||
clickable: false,
|
||||
shouldWrap: false,
|
||||
style: .new(
|
||||
color: color,
|
||||
fontWeight: .bold,
|
||||
decoration: decoration,
|
||||
decorationColor: color,
|
||||
),
|
||||
),
|
||||
Text(": "),
|
||||
],
|
||||
Flexible(
|
||||
child: IgnorePointer(
|
||||
child: EventRenderer(
|
||||
rowId,
|
||||
roomId: roomId,
|
||||
textOnly: true,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
AsyncLoading() => SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: color),
|
||||
),
|
||||
// Like if it was deleted, or the server won't share it
|
||||
_ => Text("Message not found"),
|
||||
},
|
||||
return RelatedEventLine(
|
||||
roomId,
|
||||
change.$1,
|
||||
color: color,
|
||||
decoration: decoration,
|
||||
jumpToEvent: jumpToEvent,
|
||||
);
|
||||
}),
|
||||
if (changes.length > maxShown)
|
||||
|
|
|
|||
Loading…
Reference in a new issue