getConversationVariableName method

String getConversationVariableName(
  1. Conversation conversation
)

For internal use only. Implementation detail that may change anytime.

Implementation

String getConversationVariableName(Conversation conversation) {
  if (_conversations[conversation.id] == null) {
    final variableName = 'conversation${getUniqueId()}';

    _conversations[conversation.id] = variableName;

    execute(
        'let $variableName = session.getOrCreateConversation("${conversation.id}")');

    _setConversationAttributes(variableName, conversation);
    _setConversationParticipants(variableName, conversation);

    _conversationObjs[conversation.id] = Conversation.of(conversation);
  } else if (_conversationObjs[conversation.id] != conversation) {
    final variableName = _conversations[conversation.id]!;

    _setConversationAttributes(variableName, conversation);

    if (!setEquals(conversation.participants,
        _conversationObjs[conversation.id]!.participants)) {
      _setConversationParticipants(variableName, conversation);
    }

    _conversationObjs[conversation.id] = Conversation.of(conversation);
  }

  return _conversations[conversation.id]!;
}