selfprivacy.org.app/lib/logic/cubit/backups/backups_state.dart

62 lines
1.9 KiB
Dart
Raw Normal View History

2021-12-06 20:31:19 +02:00
part of 'backups_cubit.dart';
class BackupsState extends ServerInstallationDependendState {
2021-12-06 20:31:19 +02:00
const BackupsState({
this.isInitialized = false,
this.backups = const [],
this.preventActions = true,
this.refreshTimer = const Duration(seconds: 60),
this.refreshing = true,
2023-06-29 12:52:09 +03:00
this.autobackupPeriod,
this.backblazeBucket,
this.autobackupQuotas,
2021-12-06 20:31:19 +02:00
});
final bool isInitialized;
final List<Backup> backups;
final bool preventActions;
final Duration refreshTimer;
final bool refreshing;
2023-06-29 12:52:09 +03:00
final Duration? autobackupPeriod;
final BackblazeBucket? backblazeBucket;
final AutobackupQuotas? autobackupQuotas;
2021-12-06 20:31:19 +02:00
List<Backup> serviceBackups(final String serviceId) => backups
.where((final backup) => backup.serviceId == serviceId)
.toList(growable: false);
2021-12-06 20:31:19 +02:00
@override
List<Object> get props => [
isInitialized,
backups,
preventActions,
refreshTimer,
refreshing,
2021-12-06 20:31:19 +02:00
];
BackupsState copyWith({
2022-06-05 22:36:32 +03:00
final bool? isInitialized,
final List<Backup>? backups,
final bool? preventActions,
final Duration? refreshTimer,
final bool? refreshing,
2023-06-29 12:52:09 +03:00
final Duration? autobackupPeriod,
final BackblazeBucket? backblazeBucket,
final AutobackupQuotas? autobackupQuotas,
2021-12-06 20:31:19 +02:00
}) =>
BackupsState(
isInitialized: isInitialized ?? this.isInitialized,
backups: backups ?? this.backups,
preventActions: preventActions ?? this.preventActions,
refreshTimer: refreshTimer ?? this.refreshTimer,
refreshing: refreshing ?? this.refreshing,
// The autobackupPeriod might be null, so if the duration is set to 0, we
// set it to null.
autobackupPeriod: autobackupPeriod?.inSeconds == 0
? null
: autobackupPeriod ?? this.autobackupPeriod,
2023-06-29 12:52:09 +03:00
backblazeBucket: backblazeBucket ?? this.backblazeBucket,
autobackupQuotas: autobackupQuotas ?? this.autobackupQuotas,
2021-12-06 20:31:19 +02:00
);
}