toggleChatArchivation method
Archive or unarchive the specified Chat for the authenticated MyUser.
Archived Chats are excluded from the recentChats when its with
archive
argument is set to false
.
Once a new ChatItem is posted in an archived unmuted Chat, it automatically becomes unarchived again, despite no EventChatUnarchived is emitted (which means manual unarchivation only). Muted Chats, however, are not unarchived automatically once new ChatItems are posted.
Authentication
Mandatory.
Result
One of the following ChatEvents may be produced on success:
- EventChatArchived (if
archive
argument istrue
); - EventChatUnarchived (if
archive
argument isfalse
).
Idempotent
Succeeds as no-op (and returns no ChatEvent) if the specified Chat is already archived (or unarchived) for the authenticated MyUser.
Implementation
Future<ChatEventsVersionedMixin?> toggleChatArchivation(
ChatId chatId,
bool archive,
) async {
Log.debug('toggleChatArchivation($chatId, $archive)', '$runtimeType');
final variables = ToggleChatArchivationArguments(
id: chatId,
archive: archive,
);
final QueryResult result = await client.mutate(
MutationOptions(
operationName: 'ToggleChatArchivation',
document: ToggleChatArchivationMutation(variables: variables).document,
variables: variables.toJson(),
),
onException: (data) => ToggleChatArchivationException(
(ToggleChatArchivation$Mutation.fromJson(data).toggleChatArchivation
as ToggleChatArchivation$Mutation$ToggleChatArchivation$ToggleChatArchivationError)
.code,
),
);
return (ToggleChatArchivation$Mutation.fromJson(
result.data!,
).toggleChatArchivation
as ChatEventsVersionedMixin?);
}