mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
more debugging
This commit is contained in:
parent
9219e1307e
commit
5cec423351
@ -53,9 +53,9 @@ class AccountRepository {
|
||||
static AccountRepository instance = AccountRepository._();
|
||||
|
||||
Future<void> init() async {
|
||||
await _localAccounts.load();
|
||||
await _userLogins.load();
|
||||
await _activeLocalAccount.load();
|
||||
await _localAccounts.get();
|
||||
await _userLogins.get();
|
||||
await _activeLocalAccount.get();
|
||||
await _openLoggedInDHTRecords();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||
@ -20,12 +19,10 @@ class InvitationGeneratorCubit extends FutureCubit<Uint8List> {
|
||||
class ContactInvitationDisplayDialog extends StatefulWidget {
|
||||
const ContactInvitationDisplayDialog({
|
||||
required this.message,
|
||||
required this.generator,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String message;
|
||||
final FutureOr<Uint8List> generator;
|
||||
|
||||
@override
|
||||
ContactInvitationDisplayDialogState createState() =>
|
||||
@ -34,9 +31,7 @@ class ContactInvitationDisplayDialog extends StatefulWidget {
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
..add(StringProperty('message', message))
|
||||
..add(DiagnosticsProperty<FutureOr<Uint8List>?>('generator', generator));
|
||||
properties.add(StringProperty('message', message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,6 @@ class ContactInvitationItemWidget extends StatelessWidget {
|
||||
contactInvitationRecord.invitation))),
|
||||
child: ContactInvitationDisplayDialog(
|
||||
message: contactInvitationRecord.message,
|
||||
generator: Uint8List.fromList(
|
||||
contactInvitationRecord.invitation),
|
||||
)));
|
||||
},
|
||||
title: Text(
|
||||
|
@ -13,7 +13,8 @@ import '../contact_invitation.dart';
|
||||
|
||||
class InviteDialog extends StatefulWidget {
|
||||
const InviteDialog(
|
||||
{required this.onValidationCancelled,
|
||||
{required this.modalContext,
|
||||
required this.onValidationCancelled,
|
||||
required this.onValidationSuccess,
|
||||
required this.onValidationFailed,
|
||||
required this.inviteControlIsValid,
|
||||
@ -29,6 +30,7 @@ class InviteDialog extends StatefulWidget {
|
||||
InviteDialogState dialogState,
|
||||
Future<void> Function({required Uint8List inviteData})
|
||||
validateInviteData) buildInviteControl;
|
||||
final BuildContext modalContext;
|
||||
|
||||
@override
|
||||
InviteDialogState createState() => InviteDialogState();
|
||||
@ -50,7 +52,8 @@ class InviteDialog extends StatefulWidget {
|
||||
InviteDialogState dialogState,
|
||||
Future<void> Function({required Uint8List inviteData})
|
||||
validateInviteData)>.has(
|
||||
'buildInviteControl', buildInviteControl));
|
||||
'buildInviteControl', buildInviteControl))
|
||||
..add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +72,8 @@ class InviteDialogState extends State<InviteDialog> {
|
||||
|
||||
Future<void> _onAccept() async {
|
||||
final navigator = Navigator.of(context);
|
||||
final activeAccountInfo = context.read<ActiveAccountInfo>();
|
||||
final contactList = context.read<ContactListCubit>();
|
||||
final activeAccountInfo = widget.modalContext.read<ActiveAccountInfo>();
|
||||
final contactList = widget.modalContext.read<ContactListCubit>();
|
||||
|
||||
setState(() {
|
||||
_isAccepting = true;
|
||||
@ -133,7 +136,7 @@ class InviteDialogState extends State<InviteDialog> {
|
||||
}) async {
|
||||
try {
|
||||
final contactInvitationListCubit =
|
||||
context.read<ContactInvitationListCubit>();
|
||||
widget.modalContext.read<ContactInvitationListCubit>();
|
||||
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
|
@ -8,8 +8,9 @@ import 'paste_invite_dialog.dart';
|
||||
import 'scan_invite_dialog.dart';
|
||||
import 'send_invite_dialog.dart';
|
||||
|
||||
Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
Widget newContactInvitationBottomSheetBuilder(
|
||||
BuildContext sheetContext, BuildContext context) {
|
||||
final theme = Theme.of(sheetContext);
|
||||
final textTheme = theme.textTheme;
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
|
||||
@ -17,7 +18,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
|
||||
focusNode: FocusNode(),
|
||||
onKeyEvent: (ke) {
|
||||
if (ke.logicalKey == LogicalKeyboardKey.escape) {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(sheetContext);
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
@ -30,7 +31,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
|
||||
Column(children: [
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(sheetContext);
|
||||
await SendInviteDialog.show(context);
|
||||
},
|
||||
iconSize: 64,
|
||||
@ -41,7 +42,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
|
||||
Column(children: [
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(sheetContext);
|
||||
await ScanInviteDialog.show(context);
|
||||
},
|
||||
iconSize: 64,
|
||||
@ -52,7 +53,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
|
||||
Column(children: [
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(sheetContext);
|
||||
await PasteInviteDialog.show(context);
|
||||
},
|
||||
iconSize: 64,
|
||||
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
@ -11,7 +12,7 @@ import '../../tools/tools.dart';
|
||||
import 'invite_dialog.dart';
|
||||
|
||||
class PasteInviteDialog extends StatefulWidget {
|
||||
const PasteInviteDialog({super.key});
|
||||
const PasteInviteDialog({required this.modalContext, super.key});
|
||||
|
||||
@override
|
||||
PasteInviteDialogState createState() => PasteInviteDialogState();
|
||||
@ -20,7 +21,16 @@ class PasteInviteDialog extends StatefulWidget {
|
||||
await showStyledDialog<void>(
|
||||
context: context,
|
||||
title: translate('paste_invite_dialog.title'),
|
||||
child: const PasteInviteDialog());
|
||||
child: PasteInviteDialog(modalContext: context));
|
||||
}
|
||||
|
||||
final BuildContext modalContext;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
.add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +132,7 @@ class PasteInviteDialogState extends State<PasteInviteDialog> {
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(BuildContext context) {
|
||||
return InviteDialog(
|
||||
modalContext: widget.modalContext,
|
||||
onValidationCancelled: onValidationCancelled,
|
||||
onValidationSuccess: onValidationSuccess,
|
||||
onValidationFailed: onValidationFailed,
|
||||
|
@ -104,7 +104,7 @@ class ScannerOverlay extends CustomPainter {
|
||||
}
|
||||
|
||||
class ScanInviteDialog extends StatefulWidget {
|
||||
const ScanInviteDialog({super.key});
|
||||
const ScanInviteDialog({required this.modalContext, super.key});
|
||||
|
||||
@override
|
||||
ScanInviteDialogState createState() => ScanInviteDialogState();
|
||||
@ -113,7 +113,16 @@ class ScanInviteDialog extends StatefulWidget {
|
||||
await showStyledDialog<void>(
|
||||
context: context,
|
||||
title: translate('scan_invite_dialog.title'),
|
||||
child: const ScanInviteDialog());
|
||||
child: ScanInviteDialog(modalContext: context));
|
||||
}
|
||||
|
||||
final BuildContext modalContext;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
.add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,6 +389,7 @@ class ScanInviteDialogState extends State<ScanInviteDialog> {
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(BuildContext context) {
|
||||
return InviteDialog(
|
||||
modalContext: widget.modalContext,
|
||||
onValidationCancelled: onValidationCancelled,
|
||||
onValidationSuccess: onValidationSuccess,
|
||||
onValidationFailed: onValidationFailed,
|
||||
|
@ -14,7 +14,7 @@ import '../../tools/tools.dart';
|
||||
import '../contact_invitation.dart';
|
||||
|
||||
class SendInviteDialog extends StatefulWidget {
|
||||
const SendInviteDialog({super.key});
|
||||
const SendInviteDialog({required this.modalContext, super.key});
|
||||
|
||||
@override
|
||||
SendInviteDialogState createState() => SendInviteDialogState();
|
||||
@ -23,7 +23,16 @@ class SendInviteDialog extends StatefulWidget {
|
||||
await showStyledDialog<void>(
|
||||
context: context,
|
||||
title: translate('send_invite_dialog.title'),
|
||||
child: const SendInviteDialog());
|
||||
child: SendInviteDialog(modalContext: context));
|
||||
}
|
||||
|
||||
final BuildContext modalContext;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
.add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +141,7 @@ class SendInviteDialogState extends State<SendInviteDialog> {
|
||||
|
||||
// Start generation
|
||||
final contactInvitationListCubit =
|
||||
context.read<ContactInvitationListCubit>();
|
||||
widget.modalContext.read<ContactInvitationListCubit>();
|
||||
|
||||
final generator = contactInvitationListCubit.createInvitation(
|
||||
encryptionKeyType: _encryptionKeyType,
|
||||
@ -145,10 +154,11 @@ class SendInviteDialogState extends State<SendInviteDialog> {
|
||||
}
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => ContactInvitationDisplayDialog(
|
||||
builder: (context) => BlocProvider(
|
||||
create: (context) => InvitationGeneratorCubit(generator),
|
||||
child: ContactInvitationDisplayDialog(
|
||||
message: _messageTextController.text,
|
||||
generator: generator,
|
||||
));
|
||||
)));
|
||||
// if (ret == null) {
|
||||
// return;
|
||||
// }
|
||||
|
@ -110,37 +110,38 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
|
||||
context: context,
|
||||
// ignore: prefer_expression_function_bodies
|
||||
builder: (context) {
|
||||
return const AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
return AlertDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
contentPadding: EdgeInsets.only(
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Scan Contact Invite',
|
||||
style: TextStyle(fontSize: 24),
|
||||
),
|
||||
content: ScanInviteDialog());
|
||||
content: ScanInviteDialog(
|
||||
modalContext: context,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget _onNewChatBottomSheetBuilder(BuildContext context) {
|
||||
return const SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Group and custom chat functionality is not available yet')));
|
||||
}
|
||||
Widget _onNewChatBottomSheetBuilder(
|
||||
BuildContext sheetContext, BuildContext context) =>
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Group and custom chat functionality is not available yet')));
|
||||
|
||||
Widget _bottomSheetBuilder(BuildContext context) {
|
||||
Widget _bottomSheetBuilder(BuildContext sheetContext, BuildContext context) {
|
||||
if (_currentPage == 0) {
|
||||
// New contact invitation
|
||||
return newContactInvitationBottomSheetBuilder(context);
|
||||
return newContactInvitationBottomSheetBuilder(sheetContext, context);
|
||||
} else if (_currentPage == 1) {
|
||||
// New chat
|
||||
return _onNewChatBottomSheetBuilder(context);
|
||||
return _onNewChatBottomSheetBuilder(sheetContext, context);
|
||||
} else {
|
||||
// Unknown error
|
||||
return debugPage('unknown page');
|
||||
@ -214,7 +215,8 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
|
||||
_fabIconList[_currentPage],
|
||||
color: scale.secondaryScale.text,
|
||||
),
|
||||
bottomSheetBuilder: _bottomSheetBuilder),
|
||||
bottomSheetBuilder: (sheetContext) =>
|
||||
_bottomSheetBuilder(sheetContext, context)),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
|
||||
);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,9 @@ class RouterCubit extends Cubit<RouterState> {
|
||||
// Watch for changes that the router will care about
|
||||
Future.delayed(Duration.zero, () async {
|
||||
await eventualInitialized.future;
|
||||
emit(state.copyWith(isInitialized: true));
|
||||
emit(state.copyWith(
|
||||
isInitialized: true,
|
||||
hasAnyAccount: accountRepository.getLocalAccounts().isNotEmpty));
|
||||
});
|
||||
|
||||
// Subscribe to repository streams
|
||||
|
@ -118,7 +118,7 @@ class __$$RouterStateImplCopyWithImpl<$Res>
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$RouterStateImpl implements _RouterState {
|
||||
class _$RouterStateImpl with DiagnosticableTreeMixin implements _RouterState {
|
||||
const _$RouterStateImpl(
|
||||
{required this.isInitialized,
|
||||
required this.hasAnyAccount,
|
||||
@ -135,10 +135,20 @@ class _$RouterStateImpl implements _RouterState {
|
||||
final bool hasActiveChat;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'RouterState(isInitialized: $isInitialized, hasAnyAccount: $hasAnyAccount, hasActiveChat: $hasActiveChat)';
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
..add(DiagnosticsProperty('type', 'RouterState'))
|
||||
..add(DiagnosticsProperty('isInitialized', isInitialized))
|
||||
..add(DiagnosticsProperty('hasAnyAccount', hasAnyAccount))
|
||||
..add(DiagnosticsProperty('hasActiveChat', hasActiveChat));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
|
@ -60,6 +60,13 @@ Future<VeilidConfig> getVeilidConfig(bool isWeb, String appName) async {
|
||||
config.network.routingTable.copyWith(bootstrap: bootstrap)));
|
||||
}
|
||||
|
||||
// ignore: do_not_use_environment
|
||||
const envNetworkKey = String.fromEnvironment('NETWORK_KEY');
|
||||
if (envNetworkKey.isNotEmpty) {
|
||||
config = config.copyWith(
|
||||
network: config.network.copyWith(networkKeyPassword: envNetworkKey));
|
||||
}
|
||||
|
||||
// ignore: do_not_use_environment
|
||||
const envBootstrap = String.fromEnvironment('BOOTSTRAP');
|
||||
if (envBootstrap.isNotEmpty) {
|
||||
|
Loading…
Reference in New Issue
Block a user