readRejoinCredential function
The stored credential for this room and name, or null (none, expired or unreadable).
Implementation
Future<StoredRejoinCredential?> readRejoinCredential(String roomName, String userName) async {
if (roomName.isEmpty || userName.isEmpty) return null;
try {
final prefs = await SharedPreferences.getInstance();
final raw = prefs.getString(_keyFor(roomName, userName));
if (raw == null) return null;
final decoded = jsonDecode(raw);
final value = decoded is Map<String, dynamic> ? StoredRejoinCredential.fromJson(decoded) : null;
if (value == null || DateTime.now().millisecondsSinceEpoch - value.storedAt > _maxAgeMs) {
await prefs.remove(_keyFor(roomName, userName));
return null;
}
return value;
} catch (_) {
return null;
}
}