insert method

  1. @override
void insert(
  1. Cacheable data
)
override

Implementation

@override
void insert(Cacheable data) {
  if (data is GroupChannel || data is OpenChannel) {
    if (channel != null) {
      channel?.copyWith(data);
    } else {
      channel = data as BaseChannel;
    }
  } else if (data is ReadStatus) {
    final existData = readStatus[data.key];
    if (existData != null) {
      existData.copyWith(data);
    } else {
      readStatus[data.key] = data;
    }
  } else if (data is DeliveryStatus) {
    if (deliveryStatus != null) {
      deliveryStatus!.copyWith(data);
    } else {
      deliveryStatus = data;
    }
  } else if (data is TypingStatus) {
    final existData = typingStatus[data.key];
    if (existData != null) {
      existData.copyWith(data);
    } else {
      typingStatus[data.key] = data;
    }
  } else if (data is CachedDataMap<String>) {
    if (cachedMetaData != null) {
      cachedMetaData?.merge(data);
    } else {
      cachedMetaData = data;
    }
  }
}