Remove flutter chat #26

Manually merged
Henry-Hiles merged 108 commits from remove-flutter-chat into main 2026-05-22 15:26:28 -04:00
3 changed files with 47 additions and 40 deletions
Showing only changes of commit 5c6cc1d584 - Show all commits

fix PMP rendering, add grouping

Henry Hiles 2026-05-19 22:55:29 -04:00
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -8,11 +8,6 @@ part "event.g.dart";
@freezed @freezed
abstract class Event with _$Event { abstract class Event with _$Event {
static Profile? pmpFromJson(Map<String, dynamic>? json) {
final pmp = json?["content"]?["com.beeper.per_message_profile"];
return pmp == null ? null : Profile.fromJsonWithCatch(pmp);
}
static String typeJsonFromJson(Map<dynamic, dynamic> json, _) => static String typeJsonFromJson(Map<dynamic, dynamic> json, _) =>
json["decrypted_type"] ?? json["type"]; json["decrypted_type"] ?? json["type"];
@ -43,7 +38,7 @@ abstract class Event with _$Event {
@Default(IMap.empty()) IMap<String, int> reactions, @Default(IMap.empty()) IMap<String, int> reactions,
@JsonKey(name: "last_edit_rowid") @Default(0) int lastEditRowId, @JsonKey(name: "last_edit_rowid") @Default(0) int lastEditRowId,
@UnreadTypeConverter() UnreadType? unreadType, @UnreadTypeConverter() UnreadType? unreadType,
@JsonKey(fromJson: Event.pmpFromJson) Profile? pmp, Profile? pmp,
required Content content, required Content content,
required Content? previousContent, required Content? previousContent,
}) = _Event; }) = _Event;
@ -53,6 +48,11 @@ abstract class Event with _$Event {
replyTo: getContentFromJson( replyTo: getContentFromJson(
json, json,
)["m.relates_to"]?["m.in_reply_to"]?["event_id"], )["m.relates_to"]?["m.in_reply_to"]?["event_id"],
pmp: json["content"]?["com.beeper.per_message_profile"] == null
? null
: Profile.fromJsonWithCatch(
json["content"]?["com.beeper.per_message_profile"],
),
content: Content.fromEventJson( content: Content.fromEventJson(
getContentFromJson(json), getContentFromJson(json),
json["decrypted_type"] ?? json["type"], json["decrypted_type"] ?? json["type"],

View file

@ -441,7 +441,9 @@ class EventRenderer extends ConsumerWidget {
onSecondaryTapUp: contextMenuCallback, onSecondaryTapUp: contextMenuCallback,
onLongPressStart: contextMenuCallback, onLongPressStart: contextMenuCallback,
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(vertical: 8), padding: isGrouped
? EdgeInsets.zero
: EdgeInsets.symmetric(vertical: 8),
child: child, child: child,
), ),
); );

View file

@ -333,39 +333,44 @@ class RoomChat extends HookConsumerWidget {
SuperSliverList.builder( SuperSliverList.builder(
listController: listController.value, listController: listController.value,
itemCount: value.length, itemCount: value.length,
itemBuilder: (_, index) => EventWrapper( itemBuilder: (_, index) {
value[index], final event = value[index];
EventRenderer( final previousEvent = value.getOrNull(index - 1);
value[index], return EventWrapper(
onTapReply: () async { event,
final replyId = value[index].replyTo; EventRenderer(
listController.value.animateToItem( event,
index: value.indexWhere( onTapReply: () async {
(element) => element.eventId == replyId, final replyId = event.replyTo;
), listController.value.animateToItem(
scrollController: scrollController, index: value.indexWhere(
alignment: 0.5, (element) => element.eventId == replyId,
duration: (_) => ),
Duration(milliseconds: 700), scrollController: scrollController,
curve: (_) => Curves.easeInOut, alignment: 0.5,
); duration: (_) =>
flashingEvent.value = replyId; Duration(milliseconds: 700),
await Future.delayed( curve: (_) => Curves.easeInOut,
Duration(seconds: 1), );
() { flashingEvent.value = replyId;
if (flashingEvent.value == replyId) { await Future.delayed(
flashingEvent.value = null; Duration(seconds: 1),
} () {
}, if (flashingEvent.value == replyId) {
); flashingEvent.value = null;
}, }
getEventOptions: getEventOptions, },
// TODO: Reimplement grouping );
isGrouped: false, },
), getEventOptions: getEventOptions,
isFlashing: isGrouped:
flashingEvent.value == value[index].eventId, "${event.sender}${event.pmp?.id}" ==
), "${previousEvent?.sender}${previousEvent?.pmp?.id}",
),
isFlashing:
flashingEvent.value == event.eventId,
);
},
), ),
], ],
), ),