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

View file

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