things compile

This commit is contained in:
Christien Rioux 2024-02-12 22:30:09 -05:00
parent a551791f97
commit 45ab494969
6 changed files with 42 additions and 15 deletions

View File

@ -59,8 +59,7 @@ class VeilidChatApp extends StatelessWidget {
child: BackgroundTicker(
builder: (context) => MaterialApp.router(
debugShowCheckedModeBanner: false,
routerConfig:
BlocProvider.of<RouterCubit>(context).router(),
routerConfig: context.watch<RouterCubit>().router(),
title: translate('app.title'),
theme: theme,
localizationsDelegates: [

View File

@ -127,6 +127,9 @@ class RouterCubit extends Cubit<RouterState> {
if (!state.hasAnyAccount) {
return '/new_account';
}
if (!state.hasActiveChat) { xxx stop using hasActiveChat here... we need a pager for the accounts and a way to get the current account state maybe a 'activeAccountCubit' or something, we may have this alraeady but it needs to work even if logged out.``
return '/home/no_active';
}
if (responsiveVisibility(
context: context,
tablet: false,
@ -141,6 +144,9 @@ class RouterCubit extends Cubit<RouterState> {
if (!state.hasAnyAccount) {
return '/new_account';
}
if (!state.hasActiveChat) {
return '/home/no_active';
}
if (responsiveVisibility(
context: context,
tablet: false,
@ -153,6 +159,21 @@ class RouterCubit extends Cubit<RouterState> {
return '/home';
}
return null;
case '/home/no_active':
if (state.hasActiveChat) {
return '/home';
}
return null;
case '/home/account_missing':
if (!state.hasActiveChat) {
return '/home/no_active';
}
return null;
case '/home/account_locked':
if (!state.hasActiveChat) {
return '/home/no_active';
}
return null;
case '/settings':
return null;
case '/developer':
@ -163,17 +184,24 @@ class RouterCubit extends Cubit<RouterState> {
}
/// Make a GoRouter instance that uses this cubit
GoRouter router() => GoRouter(
navigatorKey: _rootNavKey,
refreshListenable: StreamListenable(stream.startWith(state).distinct()),
debugLogDiagnostics: kDebugMode,
initialLocation: '/',
routes: routes,
redirect: redirect,
);
GoRouter router() {
final r = _router;
if (r != null) {
return r;
}
return _router = GoRouter(
navigatorKey: _rootNavKey,
refreshListenable: StreamListenable(stream.startWith(state).distinct()),
debugLogDiagnostics: kDebugMode,
initialLocation: '/',
routes: routes,
redirect: redirect,
);
}
////////////////
late final StreamSubscription<AccountRepositoryChange>
_accountRepositorySubscription;
GoRouter? _router;
}

View File

@ -28,13 +28,13 @@ class LockPreference with _$LockPreference {
// Theme supports multiple translations
enum LanguagePreference {
englishUS;
englishUs;
factory LanguagePreference.fromJson(dynamic j) =>
LanguagePreference.values.byName((j as String).toCamelCase());
String toJson() => name.toPascalCase();
static const LanguagePreference defaults = LanguagePreference.englishUS;
static const LanguagePreference defaults = LanguagePreference.englishUs;
}
// Preferences are stored in a table locally and globally affect all

View File

@ -49,7 +49,5 @@ Widget buildSettingsPageColorPreferences({required void Function() onChanged}) {
await preferencesRepository.set(newPrefs);
switcher.changeTheme(theme: newThemePrefs.themeData());
onChanged();
onChanged();
}));
}

View File

@ -44,7 +44,7 @@ Widget waitingPage({String? text}) => Builder(
color: Theme.of(context).scaffoldBackgroundColor,
child: Center(
child: Column(children: [
buildProgressIndicator(),
buildProgressIndicator().expanded(),
if (text != null) Text(text)
]))));

View File

@ -230,6 +230,8 @@ class DHTRecordPool with TableDBBacked<DHTRecordPoolAllocations> {
final dhtctx = routingContext ?? _routingContext;
final recordDescriptor = await dhtctx.createDHTRecord(schema);
await _locks.lockTag(recordDescriptor.key);
final rec = DHTRecord(
routingContext: dhtctx,
recordDescriptor: recordDescriptor,