push feature stable

This commit is contained in:
Fabian Freund
2026-07-19 14:25:48 +02:00
parent dc5e9bbd86
commit 36d85f9373
49 changed files with 5473 additions and 673 deletions
@@ -20,8 +20,10 @@
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:uuid/uuid.dart';
import 'package:weblibre/core/filesystem.dart';
import 'package:weblibre/core/logger.dart';
import 'package:weblibre/domain/entities/profile.dart';
import 'package:weblibre/features/user/data/models/auth_settings.dart';
import 'package:weblibre/features/web_push/domain/providers.dart';
part 'profile.g.dart';
@@ -37,7 +39,23 @@ class ProfileRepository extends _$ProfileRepository {
}
Future<void> switchProfile(String id) async {
await filesystem.setStartupProfile(UuidValue.withValidation(id));
final profileId = UuidValue.withValidation(id).uuid;
final pushService = ref.read(pushServiceProvider);
try {
await pushService.suspendForProfileSwitch(profileId);
} catch (error, stackTrace) {
try {
await pushService.renewRegistration();
} catch (renewError, renewStackTrace) {
logger.e(
'Failed to restore push registration after profile switch failure',
error: renewError,
stackTrace: renewStackTrace,
);
}
Error.throwWithStackTrace(error, stackTrace);
}
}
Future<Profile> createProfile({
@@ -33,7 +33,7 @@ final class ProfileRepositoryProvider
ProfileRepository create() => ProfileRepository();
}
String _$profileRepositoryHash() => r'b770e7406e1602f808cc8076c1eda67b4fce6b2d';
String _$profileRepositoryHash() => r'3055487626bdf6bdc6a51284f68eaf4067cd52ef';
abstract class _$ProfileRepository extends $AsyncNotifier<List<Profile>> {
FutureOr<List<Profile>> build();