unfavoriteChat method
- ChatId id
override
Removes the specified Chat from the favorites list of the authenticated MyUser.
Implementation
@override
Future<void> unfavoriteChat(ChatId id) async {
Log.debug('unfavoriteChat($id)', '$runtimeType');
if (id.isLocal) {
return;
}
final RxChatImpl? chat = chats[id];
final ChatFavoritePosition? oldPosition = chat?.chat.value.favoritePosition;
chat?.chat.update((c) => c?.favoritePosition = null);
paginated.emit(MapChangeNotification.updated(chat?.id, chat?.id, chat));
try {
await _graphQlProvider.unfavoriteChat(id);
} catch (e) {
chat?.chat.update((c) => c?.favoritePosition = oldPosition);
paginated.emit(MapChangeNotification.updated(chat?.id, chat?.id, chat));
rethrow;
}
}