// Version: 1.0.0 | Created: 2026-04-02 // Shared utility for generating a last-message preview string from a Room. // Used by both RoomsRepository and SyncPersistenceService to avoid duplication. import 'package:matrix/matrix.dart'; /// Returns a human-readable preview of the room's last event, or null if there /// is no suitable event to preview. String? lastMessagePreview(Room room) { final lastEvent = room.lastEvent; if (lastEvent == null) return null; return switch (lastEvent.type) { EventTypes.Message => lastEvent.body, EventTypes.Encrypted => 'Encrypted message', EventTypes.Sticker => 'Sticker', _ => null, }; }