Fix ncalbum appearing in export on unsupported server

This commit is contained in:
Ming Ming 2023-05-27 23:58:47 +08:00
parent 5bf57b33d1
commit 1d08a69b91
2 changed files with 15 additions and 1 deletions

View file

@ -8,6 +8,7 @@ import 'package:nc_photos/account.dart';
import 'package:nc_photos/app_localizations.dart'; import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/controller/account_controller.dart'; import 'package:nc_photos/controller/account_controller.dart';
import 'package:nc_photos/controller/collections_controller.dart'; import 'package:nc_photos/controller/collections_controller.dart';
import 'package:nc_photos/controller/server_controller.dart';
import 'package:nc_photos/entity/collection.dart'; import 'package:nc_photos/entity/collection.dart';
import 'package:nc_photos/entity/collection/exporter.dart'; import 'package:nc_photos/entity/collection/exporter.dart';
import 'package:nc_photos/entity/collection_item.dart'; import 'package:nc_photos/entity/collection_item.dart';
@ -40,6 +41,14 @@ class ExportCollectionDialog extends StatelessWidget {
context.read<AccountController>().collectionsController, context.read<AccountController>().collectionsController,
collection: collection, collection: collection,
items: items, items: items,
supportedProviders: {
_ProviderOption.appAlbum,
if (context
.read<AccountController>()
.serverController
.isSupported(ServerFeature.ncAlbum))
_ProviderOption.ncAlbum,
},
), ),
child: const _WrappedExportCollectionDialog(), child: const _WrappedExportCollectionDialog(),
); );
@ -171,7 +180,9 @@ class _ProviderDropdown extends StatelessWidget {
builder: (context, state) => DropdownButtonHideUnderline( builder: (context, state) => DropdownButtonHideUnderline(
child: DropdownButtonFormField<_ProviderOption>( child: DropdownButtonFormField<_ProviderOption>(
value: state.formValue.provider, value: state.formValue.provider,
items: _ProviderOption.values items: context
.read<_Bloc>()
.supportedProviders
.map((e) => DropdownMenuItem<_ProviderOption>( .map((e) => DropdownMenuItem<_ProviderOption>(
value: e, value: e,
child: Text(e.toValueString(context)), child: Text(e.toValueString(context)),

View file

@ -7,6 +7,7 @@ class _Bloc extends Bloc<_Event, _State> {
required this.collectionsController, required this.collectionsController,
required this.collection, required this.collection,
required this.items, required this.items,
required this.supportedProviders,
}) : super(_State.init()) { }) : super(_State.init()) {
on<_FormEvent>(_onFormEvent); on<_FormEvent>(_onFormEvent);
@ -78,6 +79,8 @@ class _Bloc extends Bloc<_Event, _State> {
final CollectionsController collectionsController; final CollectionsController collectionsController;
final Collection collection; final Collection collection;
final List<CollectionItem> items; final List<CollectionItem> items;
@keep
final Set<_ProviderOption> supportedProviders;
var _isHandlingError = false; var _isHandlingError = false;
} }