sticky -> clientSticky to avoid conflicts with sticky events

This commit is contained in:
Henry Hiles 2026-09-11 19:46:04 -04:00
commit 9e7fcdbef7
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 9 additions and 8 deletions

View file

@ -43,7 +43,7 @@ class RoomChatController(final String roomId)
.toEntryIList(compare: (a, b) => (a?.key ?? 0).compareTo(b?.key ?? 0)) .toEntryIList(compare: (a, b) => (a?.key ?? 0).compareTo(b?.key ?? 0))
.map((element) => element.value) .map((element) => element.value)
.toIList() .toIList()
.addAll(room.sticky) .addAll(room.clientSticky)
.map((entry) { .map((entry) {
final foundEvent = entry == null ? null : room.events[entry]; final foundEvent = entry == null ? null : room.events[entry];
@ -173,7 +173,7 @@ class RoomChatController(final String roomId)
.new({ .new({
roomId: .new( roomId: .new(
events: .new({event.rowId: event}), events: .new({event.rowId: event}),
sticky: .new({event.rowId}), clientSticky: .new({event.rowId}),
), ),
}), }),
.new(), .new(),

View file

@ -1,4 +1,5 @@
import "dart:isolate"; import "dart:isolate";
import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/models/event.dart"; import "package:nexus/models/event.dart";
@ -46,10 +47,10 @@ class RoomsController extends Notifier<IMap<String, Room>> {
roomId, roomId,
existing?.copyWith( existing?.copyWith(
hasMore: incoming.hasMore, hasMore: incoming.hasMore,
sticky: clientSticky:
(incoming.sticky.isEmpty == true (incoming.clientSticky.isEmpty == true
? existing.sticky ? existing.clientSticky
: existing.sticky.addAll(incoming.sticky)) : existing.clientSticky.addAll(incoming.clientSticky))
.removeWhere( .removeWhere(
(rowId) => incoming.timeline.values.contains(rowId), (rowId) => incoming.timeline.values.contains(rowId),
), ),

View file

@ -15,7 +15,7 @@ class const Room({
@JsonKey(fromJson: Room.timelineTupleJsonToIMap) @JsonKey(fromJson: Room.timelineTupleJsonToIMap)
final IMap<int, int?> timeline = const IMap.empty(), final IMap<int, int?> timeline = const IMap.empty(),
final ISet<int> sticky = const ISet.empty(), final ISet<int> clientSticky = const ISet.empty(),
@JsonKey(fromJson: Room.eventsJsonToIMap) @JsonKey(fromJson: Room.eventsJsonToIMap)
final IMap<int, Event> events = const IMap.empty(), final IMap<int, Event> events = const IMap.empty(),
@ -34,7 +34,7 @@ class const Room({
}) with _$Room { }) with _$Room {
/// [timeline] is an IMap of timelineRowId to eventRowId /// [timeline] is an IMap of timelineRowId to eventRowId
/// [events] is an IMap of eventRowId to event /// [events] is an IMap of eventRowId to event
/// [sticky] is an ISet of eventRowId /// [clientSticky] is an ISet of eventRowId
static IMap<int, int?> timelineTupleJsonToIMap(List<dynamic> json) => static IMap<int, int?> timelineTupleJsonToIMap(List<dynamic> json) =>
IMap.fromEntries( IMap.fromEntries(
json.map( json.map(