restoreDraft method

void restoreDraft(
  1. RCKChatProvider chatProvider
)

恢复会话草稿及其 @ 元数据和引用状态。

Implementation

void restoreDraft(RCKChatProvider chatProvider) {
  _draftChatProvider = chatProvider;
  final conversation = chatProvider.conversation;
  final draft = conversation.draft ?? '';
  _controller.text = draft;
  lastChangedText = draft;
  final storedMentions = chatProvider.engineProvider
      .getConversationDraftMentions(
        conversationType: conversation.conversationType,
        targetId: conversation.targetId,
        channelId: conversation.channelId,
      );
  _mentions
    ..clear()
    ..addAll(
      storedMentions
          .where(
            (mention) =>
                _isMentionCompatible(mention, draft, allowEmptyText: true),
          )
          .map((mention) => mention.copyWith()),
    );
  _referenceMessage = draft.isEmpty
      ? null
      : chatProvider.engineProvider.getConversationDraftReference(
          conversationType: conversation.conversationType,
          targetId: conversation.targetId,
          channelId: conversation.channelId,
        );
}