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

58 lines
1.7 KiB
Dart
Raw Normal View History

2021-12-06 18:31:19 +00:00
part of 'backups_cubit.dart';
class BackupsState extends ServerInstallationDependendState {
2021-12-06 18:31:19 +00:00
const BackupsState({
this.isInitialized = false,
this.backups = const [],
this.preventActions = true,
this.refreshTimer = const Duration(seconds: 60),
this.refreshing = true,
2023-06-29 09:52:09 +00:00
this.autobackupPeriod,
this.backblazeBucket,
2021-12-06 18:31:19 +00:00
});
final bool isInitialized;
final List<Backup> backups;
final bool preventActions;
final Duration refreshTimer;
final bool refreshing;
2023-06-29 09:52:09 +00:00
final Duration? autobackupPeriod;
final BackblazeBucket? backblazeBucket;
2021-12-06 18:31:19 +00:00
List<Backup> serviceBackups(final String serviceId) => backups
.where((final backup) => backup.serviceId == serviceId)
.toList(growable: false);
2021-12-06 18:31:19 +00:00
@override
List<Object> get props => [
isInitialized,
backups,
preventActions,
refreshTimer,
refreshing,
2021-12-06 18:31:19 +00:00
];
BackupsState copyWith({
2022-06-05 19:36:32 +00:00
final bool? isInitialized,
final List<Backup>? backups,
final bool? preventActions,
final Duration? refreshTimer,
final bool? refreshing,
2023-06-29 09:52:09 +00:00
final Duration? autobackupPeriod,
final BackblazeBucket? backblazeBucket,
2021-12-06 18:31:19 +00: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 09:52:09 +00:00
backblazeBucket: backblazeBucket ?? this.backblazeBucket,
2021-12-06 18:31:19 +00:00
);
}