You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
2 years ago
|
import 'package:neon/src/neon.dart';
|
||
2 years ago
|
import 'package:nextcloud/nextcloud.dart';
|
||
|
import 'package:rx_bloc/rx_bloc.dart';
|
||
|
import 'package:rxdart/rxdart.dart';
|
||
|
|
||
|
part 'capabilities.rxb.g.dart';
|
||
|
|
||
|
typedef Capabilities = CoreServerCapabilitiesOcsDataCapabilities;
|
||
|
typedef NextcloudTheme = CoreServerCapabilitiesOcsDataCapabilitiesTheming;
|
||
|
|
||
|
abstract class CapabilitiesBlocEvents {}
|
||
|
|
||
|
abstract class CapabilitiesBlocStates {
|
||
|
BehaviorSubject<Result<Capabilities>> get capabilities;
|
||
|
}
|
||
|
|
||
|
@RxBloc()
|
||
|
class CapabilitiesBloc extends $CapabilitiesBloc {
|
||
|
CapabilitiesBloc(
|
||
|
this._requestManager,
|
||
|
this._client,
|
||
|
) {
|
||
|
_loadCapabilities();
|
||
|
}
|
||
|
|
||
|
void _loadCapabilities() {
|
||
|
_requestManager
|
||
|
.wrapNextcloud<Capabilities, CoreServerCapabilities, void, NextcloudCoreClient>(
|
||
|
_client.id,
|
||
|
_client.core,
|
||
|
'capabilities',
|
||
|
() async => (await _client.core.getCapabilities())!,
|
||
|
(final response) => response.ocs!.data!.capabilities!,
|
||
|
preloadCache: true,
|
||
|
)
|
||
|
.listen(_capabilitiesSubject.add);
|
||
|
}
|
||
|
|
||
|
final RequestManager _requestManager;
|
||
|
final NextcloudClient _client;
|
||
|
|
||
|
final _capabilitiesSubject = BehaviorSubject<Result<Capabilities>>();
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
// ignore: discarded_futures
|
||
|
_capabilitiesSubject.close();
|
||
|
super.dispose();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
BehaviorSubject<Result<Capabilities>> _mapToCapabilitiesState() => _capabilitiesSubject;
|
||
|
}
|