syncDown method

Future<void> syncDown()

Downloads the avatar and restores embedded preferences if present.

Implementation

Future<void> syncDown() async {
  final user = await _database.select(_database.users).getSingle();
  final filename = user.avatarFilename;

  final avatarBytes = await _authRepository.withAuth(
    () => _portalService.getAvatar(filename),
  );

  final (:jpeg, :version, :data) = decodeAvatarPayload(avatarBytes);
  if (data == null || version != 0x00) return;

  await _fromMap(data);
}