feat(app): redesigned interface, polls, drafts, forwarding and mentions

A new look across the app and a set of everyday messaging features.

Interface
- Home screen with Chats, Contacts and Settings tabs, a large title,
  search across chats and message text (diacritics-insensitive), filters
  and pinned chats.
- Conversation view with a translucent header and composer, grouped
  bubbles, author avatars and colours in groups, swipe to reply, an
  "N new messages" marker, a jump-to-latest button and in-chat search.
- Contact and group profiles: verification, shared photos, groups in
  common, disappearing messages, mute, block; members, admin badges,
  adding people, rename and leave for groups.
- Full-screen photo viewer that pages through the whole conversation.
- A stable avatar colour per person and a clearly visible read state.

Messaging
- Polls in chats and groups, single or multiple choice, with votes that
  can be changed or withdrawn; older clients see them as text.
- Drafts survive leaving a chat and show in the chat list.
- Forwarding of messages, photos, files and voice messages.
- Notes to self: a local-only, encrypted chat that never reaches the
  relay.
- @mentions in groups that notify even when the group is muted.
- Typing indicators sent as ephemeral messages, opt-in and mutual like
  read receipts.
- Delivery and read times per message and per group member.
- Profile photos, cropped, resized and stripped of metadata, delivered
  encrypted to contacts.
- Voice message playback at 1.5x and 2x.
- Call buttons in 1:1 chats and call log entries.

Fixes
- Muted groups no longer notify: muting was checked against the
  author's chat instead of the group.
- A blocked contact could unblock itself by changing its delivery
  address.
- Read receipts no longer regress to delivered when a late delivery
  receipt arrives.
- A message marked as failed corrects itself once it is delivered.
- Double ticks in groups now mean delivered to every member.
This commit is contained in:
Julius Joska
2026-10-03 22:44:53 +02:00
parent 933a74c900
commit 5246a97db2
56 changed files with 12028 additions and 1668 deletions
+76 -2
View File
@@ -1,4 +1,7 @@
import 'package:sepot/models/attachment.dart';
import 'package:sepot/models/call_log.dart';
import 'package:sepot/models/group.dart';
import 'package:sepot/models/poll.dart';
import 'package:uuid/uuid.dart';
/// Typy zpráv — odpovídá Rust: MessageType
@@ -11,8 +14,8 @@ enum MessageType {
keyExchange,
}
/// Stav odeslané (mojí) zprávy — poctivá hranice: read receipts zatím
/// NEjsou (design: default OFF), takže „přečteno" se nezobrazuje.
/// Stav odeslané (mojí) zprávy. Potvrzení přečtení je volitelné (default
/// vypnuto) a reciproční — kdo ho nesdílí, „přečteno" neuvidí ani sám.
/// sending — lokálně zařazeno, čeká na potvrzení relaye (⏱)
/// sent — relay přijal, příjemce byl offline → v jeho frontě (✓)
/// delivered — doručeno na zařízení příjemce (✓✓)
@@ -43,6 +46,21 @@ class Message {
final bool isDeleted; // smazáno pro všechny (tombstone)
/// Reakce: fingerprint odesílatele reakce → emoji. Prázdné = žádné.
final Map<String, String> reactions;
/// Kdy mou zprávu dostal / přečetl který příjemce (fingerprint → čas).
/// 1:1 má nejvýš jeden záznam, skupina jeden na člena — z toho se
/// skládá „Info o zprávě". Čas je z hodin příjemce (pole `ts` doručenky).
final Map<String, DateTime> deliveredTo;
final Map<String, DateTime> readBy;
/// Anketa (textová zpráva, `content` nese záložní text pro starší appky).
final Poll? poll;
/// Fingerprinty lidí zmíněných přes @ ve skupině — zmínka projde i přes
/// ztlumení skupiny.
final List<String> mentions;
/// Lokální záznam hovoru — taková zpráva nemá text ani přílohu.
final CallLog? callLog;
const Message({
required this.id,
@@ -62,6 +80,11 @@ class Message {
this.editedAt,
this.isDeleted = false,
this.reactions = const {},
this.deliveredTo = const {},
this.readBy = const {},
this.poll,
this.mentions = const [],
this.callLog,
});
/// Vytvoř textovou zprávu
@@ -72,6 +95,8 @@ class Message {
String? replyToId,
int? disappearAfterSeconds,
MessageStatus status = MessageStatus.sending,
Poll? poll,
List<String> mentions = const [],
}) {
return Message(
id: const Uuid().v4(),
@@ -83,6 +108,8 @@ class Message {
timestamp: DateTime.now(),
status: status,
disappearAfterSeconds: disappearAfterSeconds,
poll: poll,
mentions: mentions,
);
}
@@ -137,6 +164,9 @@ class Message {
DateTime? editedAt,
bool? isDeleted,
Map<String, String>? reactions,
Map<String, DateTime>? deliveredTo,
Map<String, DateTime>? readBy,
Poll? poll,
}) {
return Message(
id: id,
@@ -156,9 +186,22 @@ class Message {
editedAt: editedAt ?? this.editedAt,
isDeleted: isDeleted ?? this.isDeleted,
reactions: reactions ?? this.reactions,
deliveredTo: deliveredTo ?? this.deliveredTo,
readBy: readBy ?? this.readBy,
poll: poll ?? this.poll,
mentions: mentions,
callLog: callLog,
);
}
/// Nejdřívější doručení / přečtení napříč příjemci (null = zatím nic).
DateTime? get firstDeliveredAt => _earliest(deliveredTo.values);
DateTime? get firstReadAt => _earliest(readBy.values);
static DateTime? _earliest(Iterable<DateTime> times) => times.isEmpty
? null
: times.reduce((a, b) => a.isBefore(b) ? a : b);
/// Má zpráva mizet?
bool get isDisappearing => disappearAfterSeconds != null;
@@ -183,8 +226,27 @@ class Message {
'editedAt': editedAt?.toIso8601String(),
'isDeleted': isDeleted,
'reactions': reactions,
'deliveredTo': _timesToJson(deliveredTo),
'readBy': _timesToJson(readBy),
'poll': poll?.toJson(),
if (mentions.isNotEmpty) 'mentions': mentions,
if (callLog != null) 'call': callLog!.toJson(),
};
static Map<String, int> _timesToJson(Map<String, DateTime> times) =>
times.map((k, v) => MapEntry(k, v.millisecondsSinceEpoch));
/// Tolerantní čtení: starší záznamy pole nemají, vadné položky se
/// přeskočí — kvůli nim nesmí spadnout načtení celé konverzace.
static Map<String, DateTime> _timesFromJson(Object? raw) {
if (raw is! Map) return const {};
return {
for (final e in raw.entries)
if (e.key is String && e.value is int)
e.key as String: DateTime.fromMillisecondsSinceEpoch(e.value as int),
};
}
factory Message.fromJson(Map<String, dynamic> json) {
return Message(
id: json['id'] as String,
@@ -215,6 +277,18 @@ class Message {
reactions: (json['reactions'] as Map<String, dynamic>?)
?.map((k, v) => MapEntry(k, v as String)) ??
const {},
deliveredTo: _timesFromJson(json['deliveredTo']),
readBy: _timesFromJson(json['readBy']),
poll: Poll.fromJson(json['poll']),
mentions: mentionsFromWire(json['mentions']),
callLog: CallLog.fromJson(json['call']),
);
}
}
/// Zmínky z drátu i z úložiště: jen řetězce a rozumný počet — obálka od
/// cizího klienta nesmí rozbít zprávu ani nafouknout úložiště.
List<String> mentionsFromWire(Object? raw) {
if (raw is! List) return const [];
return raw.whereType<String>().take(Group.maxMembers).toList();
}