async updateMessage()

in packages/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.ts [294:332]


  async updateMessage(
    messageId: string,
    content: string,
    options?: Record<string, string> | /* @conditional-compile-remove(file-sharing-acs) */ MessageOptions
  ): Promise<void> {
    return await this.asyncTeeErrorToEventEmitter(async () => {
      /* @conditional-compile-remove(file-sharing-acs) */
      const messageOptions: MessageOptions = {};
      /* @conditional-compile-remove(file-sharing-acs) */
      if (
        options &&
        // if options.attachments is an array or undefined (for removal all attachments),
        // then given options is a MessageOptions
        (Array.isArray(options.attachments) || options.attachments === undefined)
      ) {
        messageOptions.attachments = options.attachments ?? [];
      }
      /* @conditional-compile-remove(file-sharing-acs) */
      if (
        options &&
        // if options.metadata is provided, we need to add it in MessageOptions
        options.metadata &&
        typeof options.metadata === 'object'
      ) {
        messageOptions.metadata = options.metadata;
      }
      /* @conditional-compile-remove(file-sharing-acs) */
      if (options && !('attachments' in options) && !('metadata' in options)) {
        // if options don't have attachments or metadata,
        // then it is a Record<string, string>
        /* @conditional-compile-remove(file-sharing-acs) */
        return await this.handlers.onUpdateMessage(messageId, content, options);
      }
      /* @conditional-compile-remove(file-sharing-acs) */
      return await this.handlers.onUpdateMessage(messageId, content, messageOptions);
      // metadata is never used in the current stable
      return await this.handlers.onUpdateMessage(messageId, content);
    });
  }