syncUserProfileIfBearerChanged static method

Future<void> syncUserProfileIfBearerChanged(
  1. String bearerToken
)

Fetches profile when bearerToken is non-empty and either this is the first time we see this token in the current app session or the token changed from the last successful sync. Skips duplicate calls for the same token until the next app restart (in-memory only).

Implementation

static Future<void> syncUserProfileIfBearerChanged(String bearerToken) async {
  final String token = bearerToken.trim();
  if (token.isEmpty) return;
  if (_lastBearerTokenProfileSynced == token) return;
  final User? user = await getProfile();
  if (user != null) {
    _lastBearerTokenProfileSynced = token;
  }
}