A framework for building convergent cross-platform Nextcloud clients using Flutter.
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.

59 lines
1.5 KiB

import 'dart:async';
import 'package:neon/src/models/account.dart';
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 = CoreServerCapabilities_Ocs_Data;
typedef NextcloudTheme = CoreServerCapabilities_Ocs_Data_Capabilities_Theming;
2 years ago
abstract class CapabilitiesBlocEvents {
void refresh();
}
2 years ago
abstract class CapabilitiesBlocStates {
BehaviorSubject<Result<Capabilities>> get capabilities;
}
@RxBloc()
class CapabilitiesBloc extends $CapabilitiesBloc {
CapabilitiesBloc(
this._requestManager,
this._client,
) {
_$refreshEvent.listen((final _) => _loadCapabilities());
2 years ago
_loadCapabilities();
}
void _loadCapabilities() {
_requestManager
.wrapNextcloud<CoreServerCapabilities_Ocs_Data, CoreServerCapabilities>(
2 years ago
_client.id,
'capabilities',
() async => _client.core.getCapabilities(),
(final response) => response.ocs.data,
previousData: _capabilitiesSubject.valueOrNull?.data,
2 years ago
)
.listen(_capabilitiesSubject.add);
}
final RequestManager _requestManager;
final NextcloudClient _client;
final _capabilitiesSubject = BehaviorSubject<Result<Capabilities>>();
@override
void dispose() {
unawaited(_capabilitiesSubject.close());
2 years ago
super.dispose();
}
@override
BehaviorSubject<Result<Capabilities>> _mapToCapabilitiesState() => _capabilitiesSubject;
}