added support for multiple accounts with an account switcher in settings

This commit is contained in:
2026-09-27 14:54:10 +02:00
parent 5e65c4671a
commit 27563a6dc1
33 changed files with 1801 additions and 462 deletions
+22 -14
View File
@@ -15,30 +15,38 @@ import '../../state/app/modules/chat_list/bloc/chat_list_bloc.dart';
import '../../state/app/modules/nextcloud_capabilities/bloc/nextcloud_capabilities_cubit.dart';
import '../../state/app/modules/settings/bloc/settings_cubit.dart';
import '../../state/app/modules/timetable/bloc/timetable_bloc.dart';
import '../../storage/account_storage.dart';
import '../../storage/hydrated_storage_bootstrap.dart';
import '../confirm_dialog.dart';
import '../placeholder_view.dart';
import 'json_viewer.dart';
/// Lists every key persisted through [HydratedBloc.storage].
/// Lists every key persisted by the active account's blocs and the app-wide
/// settings.
class BlocStorageView extends StatefulWidget {
const BlocStorageView({super.key});
/// All persisted keys; `null` when the storage can't be enumerated.
static List<Storage> get _storages => [
HydratedBloc.storage,
AccountStorage.global,
];
/// All persisted keys; `null` when a storage can't be enumerated.
static List<String>? keys() {
final storage = HydratedBloc.storage;
if (storage is InMemoryStorage) return storage.keys.toList()..sort();
try {
// hydrated_bloc exposes no key listing; the Hive instance is the only
// way in.
// ignore: invalid_use_of_visible_for_testing_member
final box = HydratedStorage.hive.box<dynamic>('hydrated_box');
return box.keys.map((k) => '$k').toList()..sort();
} on Object {
return null;
final keys = <String>{};
for (final storage in _storages) {
final own = hydratedStorageKeys(storage);
if (own == null) return null;
keys.addAll(own);
}
return keys.toList()..sort();
}
static Storage _storageOf(String key) => _storages.firstWhere(
(storage) => hydratedStorageKeys(storage)?.contains(key) ?? false,
orElse: () => HydratedBloc.storage,
);
@override
State<BlocStorageView> createState() => _BlocStorageViewState();
}
@@ -75,7 +83,7 @@ class _BlocStorageViewState extends State<BlocStorageView> {
final keys = BlocStorageView.keys();
setState(
() => _entries = keys
?.map((k) => _Entry(k, HydratedBloc.storage.read(k)))
?.map((k) => _Entry(k, BlocStorageView._storageOf(k).read(k)))
.toList(),
);
}
@@ -114,7 +122,7 @@ class _BlocStorageViewState extends State<BlocStorageView> {
if (reset != null) {
await reset();
} else {
await HydratedBloc.storage.delete(key);
await BlocStorageView._storageOf(key).delete(key);
}
}