unstarMessage method

Future<void> unstarMessage(
  1. String starId
)

Unstar message using the star record ID.

Implementation

Future<void> unstarMessage(String starId) async {
  _ensureInitialized();
  // Get starred messages to find the message ID associated with this star
  // This is needed to update the local database
  final starred = await _registry.adapter.getStarredMessages();
  final targetStar = starred.firstWhere(
    (msg) => msg.metadata?['message_star_id'] == starId,
    orElse: () => throw ArgumentError('Star not found: $starId'),
  );

  // Update local state immediately for optimistic UI
  await _database.updateMessage(targetStar.id, isStarred: false);
  await _registry.adapter.unstarMessage(starId);
}