translationUnsubscribed function

Future<void> translationUnsubscribed(
  1. TranslationUnsubscribedOptions options
)

Handles the translation:unsubscribed socket event. Called when unsubscribed from a translation channel.

Implementation

Future<void> translationUnsubscribed(
    TranslationUnsubscribedOptions options) async {
  try {
    final data = options.data;

    // Update listen preferences
    options.updateListenPreferences?.call((prev) {
      final next = Map<String, String>.from(prev);
      next.remove(data.speakerId);
      return next;
    });

    // Stop consuming
    if (options.stopConsumingTranslation != null) {
      await options.stopConsumingTranslation!(data.speakerId, data.language);
    }
  } catch (e) {
    // Handle error silently
  }
}