renameChat method

Future<ChatEventsVersionedMixin?> renameChat(
  1. ChatId id,
  2. ChatName? name
)

Renames the specified Chat by authority of the authenticated MyUser.

Removes the Chat.name of the Chat if the provided name is null.

Only Chat-groups can be named or renamed.

Authentication

Mandatory.

Result

Only the following ChatEvent may be produced on success:

Idempotent

Succeeds as no-op (and returns no ChatEvent) if the specified Chat has the specified name already

Implementation

Future<ChatEventsVersionedMixin?> renameChat(
  ChatId id,
  ChatName? name,
) async {
  Log.debug('renameChat($id, $name)', '$runtimeType');

  RenameChatArguments variables = RenameChatArguments(id: id, name: name);
  final QueryResult result = await client.mutate(
    MutationOptions(
      operationName: 'RenameChat',
      document: RenameChatMutation(variables: variables).document,
      variables: variables.toJson(),
    ),
    onException:
        (data) => RenameChatException(
          (RenameChat$Mutation.fromJson(data).renameChat
                  as RenameChat$Mutation$RenameChat$RenameChatError)
              .code,
        ),
  );
  return (RenameChat$Mutation.fromJson(result.data!).renameChat
      as ChatEventsVersionedMixin?);
}