add settings for image packs

Closes #131
This commit is contained in:
Henry Hiles 2026-10-26 12:05:45 -04:00
commit 4b329b4c6f
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 1115 additions and 119 deletions

View file

@ -144,7 +144,7 @@ extension BuildEventOptions on Event {
(context) => EmojiPicker(
roomId: roomId,
allowFreeText: true,
onSelection: (emoji, {shortcode}) {
onSelection: (emoji, {shortcode, description}) {
Navigator.of(context).pop();
ref
.read(notifier)

View file

@ -0,0 +1,34 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:nexus/models/content/content.dart";
import "package:nexus/models/content/image_pack.dart";
import "package:nexus/models/event.dart";
import "package:nexus/models/image_pack.dart";
import "package:nexus/models/room.dart";
extension RoomImagePacks on Room {
/// The room's image packs by state key, preferring the stable type when a
/// pack has both, and leaving out deleted ones. [roomId] names those without
/// a name when the room has none either.
IMap<String, ImagePack> imagePacks(String roomId) => .fromEntries(
const [EventType.legacyImagePack, EventType.imagePack].expand(
(type) => (state[type.type] ?? .new()).entries
.map(
(entry) => switch (events[entry.value]) {
Event(redactedBy: null, content: final ImagePackContent content)
when content.hasContent =>
MapEntry(
entry.key,
ImagePack.fromContent(
content,
roomId: roomId,
roomName: metadata?.name ?? roomId,
stateKey: entry.key,
),
),
_ => null,
},
)
.nonNulls,
),
);
}