diff --git a/packages/nextcloud/lib/src/version_supported.dart b/packages/nextcloud/lib/src/version_supported.dart index 039754be..84670e3c 100644 --- a/packages/nextcloud/lib/src/version_supported.dart +++ b/packages/nextcloud/lib/src/version_supported.dart @@ -17,12 +17,18 @@ extension CoreVersionSupported on CoreClient { /// Check if the core/Server version is supported by this client /// /// Also returns the supported version number - Future<(bool, int)> isSupported(final CoreServerCapabilities_Ocs_Data capabilities) async => ( + (bool, int) isSupported(final CoreServerCapabilities_Ocs_Data capabilities) => ( capabilities.version.major == coreSupportedVersion, coreSupportedVersion, ); } +// ignore: public_member_api_docs +extension CoreStatusVersionSupported on CoreServerStatus { + /// Check if the core/Server version is supported + bool get isSupported => version.startsWith('$coreSupportedVersion.'); +} + // ignore: public_member_api_docs extension NewsVersionSupported on NewsClient { /// Check if the news app version is supported by this client @@ -42,7 +48,7 @@ extension NotesVersionSupported on NotesClient { /// Check if the notes app version is supported by this client /// /// Also returns the supported API version number - Future<(bool, int)> isSupported(final CoreServerCapabilities_Ocs_Data capabilities) async => ( + (bool, int) isSupported(final CoreServerCapabilities_Ocs_Data capabilities) => ( capabilities.capabilities.notes?.apiVersion ?.map(Version.parse) .where((final version) => version.major == notesSupportedVersion) diff --git a/packages/nextcloud/test/core_test.dart b/packages/nextcloud/test/core_test.dart index aa025dca..b9d773fb 100644 --- a/packages/nextcloud/test/core_test.dart +++ b/packages/nextcloud/test/core_test.dart @@ -17,11 +17,16 @@ Future run(final DockerImage image) async { }); tearDown(() => container.destroy()); - test('Is supported', () async { - final (supported, _) = await client.core.isSupported((await client.core.getCapabilities()).ocs.data); + test('Is supported from capabilities', () async { + final (supported, _) = client.core.isSupported((await client.core.getCapabilities()).ocs.data); expect(supported, isTrue); }); + test('Is supported from status', () async { + final status = await client.core.getStatus(); + expect(status.isSupported, isTrue); + }); + test('Get status', () async { final status = await client.core.getStatus(); expect(status.installed, true); diff --git a/packages/nextcloud/test/notes_test.dart b/packages/nextcloud/test/notes_test.dart index 954e4ef4..f226b03a 100644 --- a/packages/nextcloud/test/notes_test.dart +++ b/packages/nextcloud/test/notes_test.dart @@ -18,7 +18,7 @@ Future run(final DockerImage image) async { tearDown(() => container.destroy()); test('Is supported', () async { - final (supported, _) = await client.notes.isSupported((await client.core.getCapabilities()).ocs.data); + final (supported, _) = client.notes.isSupported((await client.core.getCapabilities()).ocs.data); expect(supported, isTrue); });