mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +01:00
Simplify server feature checking
This commit is contained in:
parent
87872def7b
commit
b42bf7d74a
2 changed files with 13 additions and 3 deletions
|
@ -11,6 +11,10 @@ import 'package:rxdart/rxdart.dart';
|
|||
|
||||
part 'server_controller.g.dart';
|
||||
|
||||
enum ServerFeature {
|
||||
ncAlbum,
|
||||
}
|
||||
|
||||
@npLog
|
||||
class ServerController {
|
||||
ServerController({
|
||||
|
@ -24,6 +28,14 @@ class ServerController {
|
|||
return _statusStreamContorller.stream;
|
||||
}
|
||||
|
||||
bool isSupported(ServerFeature feature) {
|
||||
switch (feature) {
|
||||
case ServerFeature.ncAlbum:
|
||||
return !_statusStreamContorller.hasValue ||
|
||||
_statusStreamContorller.value.majorVersion >= 25;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _load() => _getStatus();
|
||||
|
||||
Future<void> _getStatus() async {
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:nc_photos/entity/album.dart';
|
|||
import 'package:nc_photos/entity/collection.dart';
|
||||
import 'package:nc_photos/entity/collection/builder.dart';
|
||||
import 'package:nc_photos/entity/nc_album.dart';
|
||||
import 'package:nc_photos/entity/server_status.dart';
|
||||
import 'package:nc_photos/use_case/album/list_album2.dart';
|
||||
import 'package:nc_photos/use_case/nc_album/list_nc_album.dart';
|
||||
|
||||
|
@ -56,8 +55,7 @@ class ListCollection {
|
|||
onDone();
|
||||
},
|
||||
);
|
||||
if (serverController.status.hasValue &&
|
||||
serverController.status.value.majorVersion < 25) {
|
||||
if (!serverController.isSupported(ServerFeature.ncAlbum)) {
|
||||
isNcAlbumDone = true;
|
||||
} else {
|
||||
ListNcAlbum(_c)(account).listen(
|
||||
|
|
Loading…
Reference in a new issue