setStatus method

  1. @protected
  2. @visibleForTesting
void setStatus(
  1. SyncStatus status
)
inherited

Implementation

@protected
@visibleForTesting
void setStatus(SyncStatus status) {
  if (status != currentStatus) {
    // Note that currently the streaming sync implementation will never set hasSynced.
    // lastSyncedAt implies that syncing has completed at some point (hasSynced = true).
    // The previous values of hasSynced should be preserved here.
    final newStatus = status.copyWith(
        hasSynced: status.lastSyncedAt != null
            ? true
            : status.hasSynced ?? currentStatus.hasSynced,
        lastSyncedAt: status.lastSyncedAt ?? currentStatus.lastSyncedAt);
    // If the absence of hasSync was the only difference, the new states would be equal
    // and don't require an event. So, check again.
    if (newStatus != currentStatus) {
      currentStatus = newStatus;
      statusStreamController.add(currentStatus);
    }
  }
}