2022-05-24 16:09:47 +00:00
|
|
|
part of 'recovery_key_cubit.dart';
|
|
|
|
|
|
|
|
class RecoveryKeyState extends ServerInstallationDependendState {
|
|
|
|
const RecoveryKeyState(this._status, this.loadingStatus);
|
|
|
|
|
2022-05-24 18:55:39 +00:00
|
|
|
const RecoveryKeyState.initial()
|
2022-06-05 22:40:34 +00:00
|
|
|
: this(
|
|
|
|
const RecoveryKeyStatus(exists: false, valid: false),
|
|
|
|
LoadingStatus.refreshing,
|
|
|
|
);
|
2022-05-24 16:09:47 +00:00
|
|
|
|
|
|
|
final RecoveryKeyStatus _status;
|
|
|
|
final LoadingStatus loadingStatus;
|
|
|
|
|
|
|
|
bool get exists => _status.exists;
|
|
|
|
bool get isValid => _status.valid;
|
|
|
|
DateTime? get generatedAt => _status.date;
|
2022-05-26 01:02:06 +00:00
|
|
|
DateTime? get expiresAt => _status.expiration;
|
2022-05-24 16:09:47 +00:00
|
|
|
int? get usesLeft => _status.usesLeft;
|
2022-06-07 19:59:15 +00:00
|
|
|
|
|
|
|
bool get isInvalidBecauseExpired =>
|
|
|
|
_status.expiration != null &&
|
|
|
|
_status.expiration!.isBefore(DateTime.now());
|
|
|
|
|
|
|
|
bool get isInvalidBecauseUsed =>
|
|
|
|
_status.usesLeft != null && _status.usesLeft == 0;
|
|
|
|
|
2022-05-24 16:09:47 +00:00
|
|
|
@override
|
|
|
|
List<Object> get props => [_status, loadingStatus];
|
|
|
|
|
|
|
|
RecoveryKeyState copyWith({
|
2022-06-05 19:36:32 +00:00
|
|
|
final RecoveryKeyStatus? status,
|
|
|
|
final LoadingStatus? loadingStatus,
|
2022-06-05 22:40:34 +00:00
|
|
|
}) =>
|
|
|
|
RecoveryKeyState(
|
|
|
|
status ?? _status,
|
|
|
|
loadingStatus ?? this.loadingStatus,
|
|
|
|
);
|
2022-05-24 16:09:47 +00:00
|
|
|
}
|