keep message drafts on room switches

this is for you courge
This commit is contained in:
Henry Hiles 2026-11-05 20:44:13 -05:00
commit e899bb3929
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -0,0 +1,29 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:fluttertagger/fluttertagger.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/bot_command_draft.dart";
import "package:nexus/models/content/image_pack.dart";
import "package:nexus/models/content/message.dart";
import "package:nexus/models/content/poll_start.dart";
import "package:nexus/models/relation_type.dart";
part "composer_draft.freezed.dart";
@Freezed(toJson: false, fromJson: false)
class const ComposerDraft({
// Formatted like ":id#name#", see the composer's tagTextFormatter
final String text = "",
final IList<Tag> tags = const .empty(),
final int? relatedEvent,
final RelationType relationType = .reply,
// Replace the text field until they are sent or removed
final (String, PackImage)? sticker,
final PollStart? poll,
final LocationMessageContent? location,
// The draft from before an edit, restored once it is sent or cancelled
final ({ComposerDraft draft, BotCommandDraft? botCommand})? beforeEdit,
}) with _$ComposerDraft {
bool get isEditing => beforeEdit != null;
}