asnasd/lib/controllers/unified_push_allowed.dart
Henry-Hiles 9d495410f6
make webpush enabled check better
Because Continuwuity sends a VAPID even when webpush is disabled.
2026-12-02 13:50:34 -05:00

37 lines
1.1 KiB
Dart

import "dart:io";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/capabilities.dart";
import "package:nexus/controllers/unified_push_distributors.dart";
class UnifiedPushAllowedController extends AsyncNotifier<String?> {
@override
Future<String?> build() async {
final distributors = await ref.watch(
UnifiedPushDistributorsController.provider.future,
);
if (distributors.isEmpty) {
return "No valid distributors found. ${Platform.isLinux
? "Try installing KUnifiedPush"
: Platform.isAndroid
? "Try installing Google Play Services or NTFY"
: "Your platform is not currently supported by UnifiedPush"}.";
}
final capabilities = await ref.watch(
CapabilitiesController.provider.future,
);
if (capabilities.webPushVapid == 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,
);
}