updateMetaData method

Future<Map<String, String>> updateMetaData(
  1. Map<String, String> metaData
)

Updates meta data.

Implementation

Future<Map<String, String>> updateMetaData(
    Map<String, String> metaData) async {
  sbLog.i(StackTrace.current, 'metaData: $metaData');
  checkUnsupportedAction();

  if (metaData.isEmpty) {
    throw InvalidParameterException();
  }

  final result = await chat.apiClient.send<MetaDataResponse>(
    ChannelMetaDataUpdateRequest(
      chat,
      channelType: channelType,
      channelUrl: channelUrl,
      metaData: metaData,
    ),
  );

  final cached =
      chat.channelCache.find<MetaDataCache>(channelKey: channelUrl) ??
          MetaDataCache<String>(
            channelType: channelType,
            channelUrl: channelUrl,
            timestamp: result.ts,
          );
  cached.addMap(result.metadata, result.ts);
  cached.saveToCache(chat);

  return result.metadata;
}