mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 09:31:13 +00:00
refactor: Remove unused providers cubit
This commit is contained in:
parent
fa21bdf034
commit
24e5c8baee
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:selfprivacy/logic/cubit/connection_status/connection_status_bloc.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/devices/devices_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/devices/devices_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/recovery_key/recovery_key_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/recovery_key/recovery_key_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
||||||
|
@ -8,7 +9,6 @@ import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
|
||||||
import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
||||||
|
@ -55,9 +55,6 @@ class BlocAndProviderConfig extends StatelessWidget {
|
||||||
create: (final _) => serverInstallationCubit,
|
create: (final _) => serverInstallationCubit,
|
||||||
lazy: false,
|
lazy: false,
|
||||||
),
|
),
|
||||||
BlocProvider(
|
|
||||||
create: (final _) => ProvidersCubit(),
|
|
||||||
),
|
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (final _) => usersCubit..load(),
|
create: (final _) => usersCubit..load(),
|
||||||
lazy: false,
|
lazy: false,
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/provider.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
|
||||||
|
|
||||||
export 'package:selfprivacy/logic/models/state_types.dart';
|
|
||||||
export 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
part 'providers_state.dart';
|
|
||||||
|
|
||||||
class ProvidersCubit extends Cubit<ProvidersState> {
|
|
||||||
ProvidersCubit() : super(InitialProviderState());
|
|
||||||
|
|
||||||
void connect(final ProviderModel provider) {
|
|
||||||
final ProvidersState newState =
|
|
||||||
state.updateElement(provider, StateType.stable);
|
|
||||||
emit(newState);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
part of 'providers_cubit.dart';
|
|
||||||
|
|
||||||
class ProvidersState extends Equatable {
|
|
||||||
const ProvidersState(this.all);
|
|
||||||
|
|
||||||
final List<ProviderModel> all;
|
|
||||||
|
|
||||||
ProvidersState updateElement(
|
|
||||||
final ProviderModel provider,
|
|
||||||
final StateType newState,
|
|
||||||
) {
|
|
||||||
final List<ProviderModel> newList = [...all];
|
|
||||||
final int index = newList.indexOf(provider);
|
|
||||||
newList[index] = provider.updateState(newState);
|
|
||||||
return ProvidersState(newList);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ProviderModel> get connected => all
|
|
||||||
.where((final service) => service.state != StateType.uninitialized)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
List<ProviderModel> get uninitialized => all
|
|
||||||
.where((final service) => service.state == StateType.uninitialized)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
bool get isFullyInitialized => uninitialized.isEmpty;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => all;
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitialProviderState extends ProvidersState {
|
|
||||||
InitialProviderState()
|
|
||||||
: super(
|
|
||||||
ProviderType.values
|
|
||||||
.map(
|
|
||||||
(final type) => ProviderModel(
|
|
||||||
state: StateType.uninitialized,
|
|
||||||
type: type,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -4,9 +4,9 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||||
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||||
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
||||||
import 'package:selfprivacy/logic/models/disk_status.dart';
|
import 'package:selfprivacy/logic/models/disk_status.dart';
|
||||||
import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart';
|
import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart';
|
||||||
|
|
Loading…
Reference in a new issue