push feature stable
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ Future<bool?> showSwitchProfileDialog(
|
||||
icon: const Icon(Icons.warning),
|
||||
title: const Text('Switch User'),
|
||||
content: Text(
|
||||
"Switching to User '$profileName' will require a restart of the Browser.\n\nPrivate tab data will be cleared on restart.",
|
||||
"Switching to User '$profileName' will require a restart of the Browser. Web notifications for the inactive profile will be paused.\n\nPrivate tab data will be cleared on restart.",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
actions: [
|
||||
|
||||
+10
-3
@@ -55,9 +55,16 @@ Future<void> handleSwitchProfile(
|
||||
);
|
||||
|
||||
if (shouldSwitch == true) {
|
||||
await ref
|
||||
.read(profileRepositoryProvider.notifier)
|
||||
.switchProfile(profile.id);
|
||||
try {
|
||||
await ref
|
||||
.read(profileRepositoryProvider.notifier)
|
||||
.switchProfile(profile.id);
|
||||
} catch (error) {
|
||||
if (context.mounted) {
|
||||
ui_helper.showErrorMessage(context, 'Could not switch profile: $error');
|
||||
}
|
||||
return;
|
||||
}
|
||||
await exitApp(ref.container);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user