add UnifiedPushAllowedController
This commit is contained in:
parent
fe871217b2
commit
7218eb5195
3 changed files with 67 additions and 16 deletions
33
lib/controllers/unified_push_allowed.dart
Normal file
33
lib/controllers/unified_push_allowed.dart
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import "dart:io";
|
||||
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/client.dart";
|
||||
import "package:unifiedpush/unifiedpush.dart";
|
||||
|
||||
class UnifiedPushAllowedController extends AsyncNotifier<String?> {
|
||||
@override
|
||||
Future<String?> build() async {
|
||||
if (!await UnifiedPush.tryUseCurrentOrDefaultDistributor()) {
|
||||
return "No valid distributors found. Try installing ${Platform.isLinux
|
||||
? "KUnifiedPush"
|
||||
: Platform.isAndroid
|
||||
? "FCM or NTFY"
|
||||
: "NTFY"}.";
|
||||
}
|
||||
|
||||
final capabilities = await ref
|
||||
.watch(ClientController.provider.notifier)
|
||||
.getCapabilities();
|
||||
|
||||
if (capabilities.webpush?.vapid == null) {
|
||||
return "Your homeserver does not support MSC4174 (Web Push), and therefore cannot send notifications to Nexus.";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static final provider =
|
||||
AsyncNotifierProvider.autoDispose<UnifiedPushAllowedController, String?>(
|
||||
UnifiedPushAllowedController.new,
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue