mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-06-07 14:12:41 -04:00
deadlock cleanup
This commit is contained in:
parent
23867a1784
commit
2141dbff21
40 changed files with 254 additions and 253 deletions
|
@ -23,7 +23,6 @@ class AccountInfoCubit extends Cubit<AccountInfo> {
|
||||||
if (acctInfo != null) {
|
if (acctInfo != null) {
|
||||||
emit(acctInfo);
|
emit(acctInfo);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ class LocalAccountsCubit extends Cubit<LocalAccountsState>
|
||||||
switch (change) {
|
switch (change) {
|
||||||
case AccountRepositoryChange.localAccounts:
|
case AccountRepositoryChange.localAccounts:
|
||||||
emit(_accountRepository.getLocalAccounts());
|
emit(_accountRepository.getLocalAccounts());
|
||||||
break;
|
|
||||||
// Ignore these
|
// Ignore these
|
||||||
case AccountRepositoryChange.userLogins:
|
case AccountRepositoryChange.userLogins:
|
||||||
case AccountRepositoryChange.activeLocalAccount:
|
case AccountRepositoryChange.activeLocalAccount:
|
||||||
|
|
|
@ -15,6 +15,9 @@ import '../../notifications/notifications.dart';
|
||||||
import '../../proto/proto.dart' as proto;
|
import '../../proto/proto.dart' as proto;
|
||||||
import '../account_manager.dart';
|
import '../account_manager.dart';
|
||||||
|
|
||||||
|
const _kAccountRecordSubscriptionListenKey =
|
||||||
|
'accountRecordSubscriptionListenKey';
|
||||||
|
|
||||||
class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
PerAccountCollectionCubit({
|
PerAccountCollectionCubit({
|
||||||
required Locator locator,
|
required Locator locator,
|
||||||
|
@ -32,6 +35,7 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
await _processor.close();
|
await _processor.close();
|
||||||
await accountInfoCubit.close();
|
await accountInfoCubit.close();
|
||||||
await _accountRecordSubscription?.cancel();
|
await _accountRecordSubscription?.cancel();
|
||||||
|
await serialFutureClose((this, _kAccountRecordSubscriptionListenKey));
|
||||||
await accountRecordCubit?.close();
|
await accountRecordCubit?.close();
|
||||||
|
|
||||||
await activeSingleContactChatBlocMapCubitUpdater.close();
|
await activeSingleContactChatBlocMapCubitUpdater.close();
|
||||||
|
@ -83,7 +87,7 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
accountRecordCubit = null;
|
accountRecordCubit = null;
|
||||||
|
|
||||||
// Update state to 'loading'
|
// Update state to 'loading'
|
||||||
nextState = _updateAccountRecordState(nextState, null);
|
nextState = await _updateAccountRecordState(nextState, null);
|
||||||
emit(nextState);
|
emit(nextState);
|
||||||
} else {
|
} else {
|
||||||
///////////////// Logged in ///////////////////
|
///////////////// Logged in ///////////////////
|
||||||
|
@ -95,20 +99,22 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
|
|
||||||
// Update state to value
|
// Update state to value
|
||||||
nextState =
|
nextState =
|
||||||
_updateAccountRecordState(nextState, accountRecordCubit!.state);
|
await _updateAccountRecordState(nextState, accountRecordCubit!.state);
|
||||||
emit(nextState);
|
emit(nextState);
|
||||||
|
|
||||||
// Subscribe AccountRecordCubit
|
// Subscribe AccountRecordCubit
|
||||||
_accountRecordSubscription ??=
|
_accountRecordSubscription ??=
|
||||||
accountRecordCubit!.stream.listen((avAccountRecordState) {
|
accountRecordCubit!.stream.listen((avAccountRecordState) {
|
||||||
emit(_updateAccountRecordState(state, avAccountRecordState));
|
serialFuture((this, _kAccountRecordSubscriptionListenKey), () async {
|
||||||
|
emit(await _updateAccountRecordState(state, avAccountRecordState));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PerAccountCollectionState _updateAccountRecordState(
|
Future<PerAccountCollectionState> _updateAccountRecordState(
|
||||||
PerAccountCollectionState prevState,
|
PerAccountCollectionState prevState,
|
||||||
AsyncValue<AccountRecordState>? avAccountRecordState) {
|
AsyncValue<AccountRecordState>? avAccountRecordState) async {
|
||||||
// Get next state
|
// Get next state
|
||||||
final nextState =
|
final nextState =
|
||||||
prevState.copyWith(avAccountRecordState: avAccountRecordState);
|
prevState.copyWith(avAccountRecordState: avAccountRecordState);
|
||||||
|
@ -121,8 +127,8 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
.avAccountRecordState?.asData?.value.contactInvitationRecords
|
.avAccountRecordState?.asData?.value.contactInvitationRecords
|
||||||
.toVeilid();
|
.toVeilid();
|
||||||
|
|
||||||
final contactInvitationListCubit = contactInvitationListCubitUpdater.update(
|
final contactInvitationListCubit = await contactInvitationListCubitUpdater
|
||||||
accountInfo.userLogin == null ||
|
.update(accountInfo.userLogin == null ||
|
||||||
contactInvitationListRecordPointer == null
|
contactInvitationListRecordPointer == null
|
||||||
? null
|
? null
|
||||||
: (accountInfo, contactInvitationListRecordPointer));
|
: (accountInfo, contactInvitationListRecordPointer));
|
||||||
|
@ -131,14 +137,15 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
final contactListRecordPointer =
|
final contactListRecordPointer =
|
||||||
nextState.avAccountRecordState?.asData?.value.contactList.toVeilid();
|
nextState.avAccountRecordState?.asData?.value.contactList.toVeilid();
|
||||||
|
|
||||||
final contactListCubit = contactListCubitUpdater.update(
|
final contactListCubit = await contactListCubitUpdater.update(
|
||||||
accountInfo.userLogin == null || contactListRecordPointer == null
|
accountInfo.userLogin == null || contactListRecordPointer == null
|
||||||
? null
|
? null
|
||||||
: (accountInfo, contactListRecordPointer));
|
: (accountInfo, contactListRecordPointer));
|
||||||
|
|
||||||
// WaitingInvitationsBlocMapCubit
|
// WaitingInvitationsBlocMapCubit
|
||||||
final waitingInvitationsBlocMapCubit = waitingInvitationsBlocMapCubitUpdater
|
final waitingInvitationsBlocMapCubit =
|
||||||
.update(accountInfo.userLogin == null ||
|
await waitingInvitationsBlocMapCubitUpdater.update(
|
||||||
|
accountInfo.userLogin == null ||
|
||||||
contactInvitationListCubit == null ||
|
contactInvitationListCubit == null ||
|
||||||
contactListCubit == null
|
contactListCubit == null
|
||||||
? null
|
? null
|
||||||
|
@ -151,14 +158,14 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
));
|
));
|
||||||
|
|
||||||
// ActiveChatCubit
|
// ActiveChatCubit
|
||||||
final activeChatCubit = activeChatCubitUpdater
|
final activeChatCubit = await activeChatCubitUpdater
|
||||||
.update((accountInfo.userLogin == null) ? null : true);
|
.update((accountInfo.userLogin == null) ? null : true);
|
||||||
|
|
||||||
// ChatListCubit
|
// ChatListCubit
|
||||||
final chatListRecordPointer =
|
final chatListRecordPointer =
|
||||||
nextState.avAccountRecordState?.asData?.value.chatList.toVeilid();
|
nextState.avAccountRecordState?.asData?.value.chatList.toVeilid();
|
||||||
|
|
||||||
final chatListCubit = chatListCubitUpdater.update(
|
final chatListCubit = await chatListCubitUpdater.update(
|
||||||
accountInfo.userLogin == null ||
|
accountInfo.userLogin == null ||
|
||||||
chatListRecordPointer == null ||
|
chatListRecordPointer == null ||
|
||||||
activeChatCubit == null
|
activeChatCubit == null
|
||||||
|
@ -167,7 +174,7 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
|
|
||||||
// ActiveConversationsBlocMapCubit
|
// ActiveConversationsBlocMapCubit
|
||||||
final activeConversationsBlocMapCubit =
|
final activeConversationsBlocMapCubit =
|
||||||
activeConversationsBlocMapCubitUpdater.update(
|
await activeConversationsBlocMapCubitUpdater.update(
|
||||||
accountRecordCubit == null ||
|
accountRecordCubit == null ||
|
||||||
chatListCubit == null ||
|
chatListCubit == null ||
|
||||||
contactListCubit == null
|
contactListCubit == null
|
||||||
|
@ -181,7 +188,7 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
||||||
|
|
||||||
// ActiveSingleContactChatBlocMapCubit
|
// ActiveSingleContactChatBlocMapCubit
|
||||||
final activeSingleContactChatBlocMapCubit =
|
final activeSingleContactChatBlocMapCubit =
|
||||||
activeSingleContactChatBlocMapCubitUpdater.update(
|
await activeSingleContactChatBlocMapCubitUpdater.update(
|
||||||
accountInfo.userLogin == null ||
|
accountInfo.userLogin == null ||
|
||||||
activeConversationsBlocMapCubit == null
|
activeConversationsBlocMapCubit == null
|
||||||
? null
|
? null
|
||||||
|
|
|
@ -17,7 +17,6 @@ class UserLoginsCubit extends Cubit<UserLoginsState> {
|
||||||
switch (change) {
|
switch (change) {
|
||||||
case AccountRepositoryChange.userLogins:
|
case AccountRepositoryChange.userLogins:
|
||||||
emit(_accountRepository.getUserLogins());
|
emit(_accountRepository.getUserLogins());
|
||||||
break;
|
|
||||||
// Ignore these
|
// Ignore these
|
||||||
case AccountRepositoryChange.localAccounts:
|
case AccountRepositoryChange.localAccounts:
|
||||||
case AccountRepositoryChange.activeLocalAccount:
|
case AccountRepositoryChange.activeLocalAccount:
|
||||||
|
|
|
@ -61,6 +61,13 @@ class _EditAccountPageState extends WindowSetupState<EditAccountPage> {
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<void> _onRemoveAccount() async {
|
Future<void> _onRemoveAccount() async {
|
||||||
|
// dismiss the keyboard by unfocusing the textfield
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
await asyncSleep(const Duration(milliseconds: 250));
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final confirmed = await StyledDialog.show<bool>(
|
final confirmed = await StyledDialog.show<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
title: translate('edit_account_page.remove_account_confirm'),
|
title: translate('edit_account_page.remove_account_confirm'),
|
||||||
|
@ -87,10 +94,7 @@ class _EditAccountPageState extends WindowSetupState<EditAccountPage> {
|
||||||
]))
|
]))
|
||||||
]).paddingAll(24)
|
]).paddingAll(24)
|
||||||
]));
|
]));
|
||||||
if (confirmed != null && confirmed && mounted) {
|
if (confirmed != null && confirmed) {
|
||||||
// dismiss the keyboard by unfocusing the textfield
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isInAsyncCall = true;
|
_isInAsyncCall = true;
|
||||||
|
@ -125,6 +129,13 @@ class _EditAccountPageState extends WindowSetupState<EditAccountPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onDestroyAccount() async {
|
Future<void> _onDestroyAccount() async {
|
||||||
|
// dismiss the keyboard by unfocusing the textfield
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
await asyncSleep(const Duration(milliseconds: 250));
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final confirmed = await StyledDialog.show<bool>(
|
final confirmed = await StyledDialog.show<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
title: translate('edit_account_page.destroy_account_confirm'),
|
title: translate('edit_account_page.destroy_account_confirm'),
|
||||||
|
@ -154,10 +165,7 @@ class _EditAccountPageState extends WindowSetupState<EditAccountPage> {
|
||||||
]))
|
]))
|
||||||
]).paddingAll(24)
|
]).paddingAll(24)
|
||||||
]));
|
]));
|
||||||
if (confirmed != null && confirmed && mounted) {
|
if (confirmed != null && confirmed) {
|
||||||
// dismiss the keyboard by unfocusing the textfield
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isInAsyncCall = true;
|
_isInAsyncCall = true;
|
||||||
|
|
|
@ -282,9 +282,6 @@ class _EditProfileFormState extends State<EditProfileForm> {
|
||||||
FormBuilderCheckbox(
|
FormBuilderCheckbox(
|
||||||
name: EditProfileForm.formFieldAutoAway,
|
name: EditProfileForm.formFieldAutoAway,
|
||||||
initialValue: _savedValue.autoAway,
|
initialValue: _savedValue.autoAway,
|
||||||
side: BorderSide(color: scale.primaryScale.border, width: 2),
|
|
||||||
checkColor: scale.primaryScale.borderText,
|
|
||||||
activeColor: scale.primaryScale.border,
|
|
||||||
title: Text(translate('account.form_auto_away'),
|
title: Text(translate('account.form_auto_away'),
|
||||||
style: textTheme.labelMedium),
|
style: textTheme.labelMedium),
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ class VeilidChatApp extends StatelessWidget {
|
||||||
|
|
||||||
final ThemeData initialThemeData;
|
final ThemeData initialThemeData;
|
||||||
|
|
||||||
void _reloadTheme(BuildContext context) {
|
void reloadTheme(BuildContext context) {
|
||||||
singleFuture(this, () async {
|
singleFuture(this, () async {
|
||||||
log.info('Reloading theme');
|
log.info('Reloading theme');
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class VeilidChatApp extends StatelessWidget {
|
||||||
},
|
},
|
||||||
child: Actions(actions: <Type, Action<Intent>>{
|
child: Actions(actions: <Type, Action<Intent>>{
|
||||||
ReloadThemeIntent: CallbackAction<ReloadThemeIntent>(
|
ReloadThemeIntent: CallbackAction<ReloadThemeIntent>(
|
||||||
onInvoke: (intent) => _reloadTheme(context)),
|
onInvoke: (intent) => reloadTheme(context)),
|
||||||
AttachDetachIntent: CallbackAction<AttachDetachIntent>(
|
AttachDetachIntent: CallbackAction<AttachDetachIntent>(
|
||||||
onInvoke: (intent) => _attachDetach(context)),
|
onInvoke: (intent) => _attachDetach(context)),
|
||||||
}, child: Focus(autofocus: true, child: builder(context)))));
|
}, child: Focus(autofocus: true, child: builder(context)))));
|
||||||
|
|
|
@ -120,7 +120,7 @@ class ChatComponentWidget extends StatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: 40,
|
height: 48,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: scale.border,
|
color: scale.border,
|
||||||
),
|
),
|
||||||
|
|
|
@ -86,14 +86,12 @@ class ChatListCubit extends DHTShortArrayCubit<proto.Chat>
|
||||||
// Nothing to do here
|
// Nothing to do here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case proto.Chat_Kind.group:
|
case proto.Chat_Kind.group:
|
||||||
if (c.group.localConversationRecordKey ==
|
if (c.group.localConversationRecordKey ==
|
||||||
contact.localConversationRecordKey) {
|
contact.localConversationRecordKey) {
|
||||||
throw StateError('direct conversation record key should'
|
throw StateError('direct conversation record key should'
|
||||||
' not be used for group chats!');
|
' not be used for group chats!');
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case proto.Chat_Kind.notSet:
|
case proto.Chat_Kind.notSet:
|
||||||
throw StateError('unknown chat kind');
|
throw StateError('unknown chat kind');
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,7 @@ class _CreateInvitationDialogState extends State<CreateInvitationDialog> {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextField(
|
TextField(
|
||||||
|
autofocus: true,
|
||||||
controller: _recipientTextController,
|
controller: _recipientTextController,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ScannerOverlay extends CustomPainter {
|
||||||
final cutoutPath = Path()..addRect(scanWindow);
|
final cutoutPath = Path()..addRect(scanWindow);
|
||||||
|
|
||||||
final backgroundPaint = Paint()
|
final backgroundPaint = Paint()
|
||||||
..color = Colors.black.withOpacity(0.5)
|
..color = Colors.black.withAlpha(127)
|
||||||
..style = PaintingStyle.fill
|
..style = PaintingStyle.fill
|
||||||
..blendMode = BlendMode.dstOut;
|
..blendMode = BlendMode.dstOut;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class ScanInvitationDialogState extends State<ScanInvitationDialog> {
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
height: 100,
|
height: 100,
|
||||||
color: Colors.black.withOpacity(0.4),
|
color: Colors.black.withAlpha(127),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -149,10 +149,14 @@ class ContactListCubit extends DHTShortArrayCubit<proto.Contact> {
|
||||||
// Mark the conversation records for deletion
|
// Mark the conversation records for deletion
|
||||||
await DHTRecordPool.instance
|
await DHTRecordPool.instance
|
||||||
.deleteRecord(deletedItem.localConversationRecordKey.toVeilid());
|
.deleteRecord(deletedItem.localConversationRecordKey.toVeilid());
|
||||||
|
} on Exception catch (e) {
|
||||||
|
log.debug('error deleting local conversation record: $e', e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
await DHTRecordPool.instance
|
await DHTRecordPool.instance
|
||||||
.deleteRecord(deletedItem.remoteConversationRecordKey.toVeilid());
|
.deleteRecord(deletedItem.remoteConversationRecordKey.toVeilid());
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
log.debug('error deleting conversation records: $e', e);
|
log.debug('error deleting remote conversation record: $e', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,9 +195,6 @@ class _EditContactFormState extends State<EditContactForm> {
|
||||||
FormBuilderCheckbox(
|
FormBuilderCheckbox(
|
||||||
name: EditContactForm.formFieldShowAvailability,
|
name: EditContactForm.formFieldShowAvailability,
|
||||||
initialValue: _savedValue.showAvailability,
|
initialValue: _savedValue.showAvailability,
|
||||||
side: BorderSide(color: scale.primaryScale.border, width: 2),
|
|
||||||
checkColor: scale.primaryScale.borderText,
|
|
||||||
activeColor: scale.primaryScale.border,
|
|
||||||
title: Text(translate('contact_form.form_show_availability'),
|
title: Text(translate('contact_form.form_show_availability'),
|
||||||
style: textTheme.labelMedium),
|
style: textTheme.labelMedium),
|
||||||
),
|
),
|
||||||
|
|
|
@ -15,8 +15,7 @@ class EmptyContactListWidget extends StatelessWidget {
|
||||||
final textTheme = theme.textTheme;
|
final textTheme = theme.textTheme;
|
||||||
final scale = theme.extension<ScaleScheme>()!;
|
final scale = theme.extension<ScaleScheme>()!;
|
||||||
|
|
||||||
return Expanded(
|
return Column(
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
@ -35,6 +34,6 @@ class EmptyContactListWidget extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ typedef ActiveConversationsBlocMapState
|
||||||
// We currently only build the cubits for the chats that are active, not
|
// We currently only build the cubits for the chats that are active, not
|
||||||
// archived chats or contacts that are not actively in a chat.
|
// archived chats or contacts that are not actively in a chat.
|
||||||
//
|
//
|
||||||
// TODO: Polling contacts for new inactive chats is yet to be done
|
// TODO(crioux): Polling contacts for new inactive chats is yet to be done
|
||||||
//
|
//
|
||||||
class ActiveConversationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
class ActiveConversationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
||||||
AsyncValue<ActiveConversationState>, ActiveConversationCubit>
|
AsyncValue<ActiveConversationState>, ActiveConversationCubit>
|
||||||
|
@ -166,7 +166,6 @@ class ActiveConversationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
||||||
localConversationRecordKey: localConversationRecordKey,
|
localConversationRecordKey: localConversationRecordKey,
|
||||||
remoteConversationRecordKey: remoteConversationRecordKey);
|
remoteConversationRecordKey: remoteConversationRecordKey);
|
||||||
|
|
||||||
break;
|
|
||||||
case proto.Chat_Kind.group:
|
case proto.Chat_Kind.group:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:go_router/go_router.dart';
|
||||||
import 'package:veilid_support/veilid_support.dart';
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
|
|
||||||
import '../../../account_manager/account_manager.dart';
|
import '../../../account_manager/account_manager.dart';
|
||||||
|
import '../../../app.dart';
|
||||||
import '../../../theme/theme.dart';
|
import '../../../theme/theme.dart';
|
||||||
import '../../../tools/tools.dart';
|
import '../../../tools/tools.dart';
|
||||||
import '../../../veilid_processor/veilid_processor.dart';
|
import '../../../veilid_processor/veilid_processor.dart';
|
||||||
|
@ -362,12 +363,18 @@ class _DrawerMenuState extends State<DrawerMenu> {
|
||||||
// ? grayColorFilter
|
// ? grayColorFilter
|
||||||
// : null)
|
// : null)
|
||||||
// .paddingLTRB(0, 0, 16, 0),
|
// .paddingLTRB(0, 0, 16, 0),
|
||||||
SvgPicture.asset(
|
GestureDetector(
|
||||||
|
onLongPress: () async {
|
||||||
|
context
|
||||||
|
.findAncestorWidgetOfExactType<VeilidChatApp>()!
|
||||||
|
.reloadTheme(context);
|
||||||
|
},
|
||||||
|
child: SvgPicture.asset(
|
||||||
height: 48,
|
height: 48,
|
||||||
'assets/images/title.svg',
|
'assets/images/title.svg',
|
||||||
colorFilter: scaleConfig.useVisualIndicators
|
colorFilter: scaleConfig.useVisualIndicators
|
||||||
? grayColorFilter
|
? grayColorFilter
|
||||||
: src96StencilFilter),
|
: src96StencilFilter)),
|
||||||
]))),
|
]))),
|
||||||
Text(translate('menu.accounts'),
|
Text(translate('menu.accounts'),
|
||||||
style: theme.textTheme.titleMedium!.copyWith(
|
style: theme.textTheme.titleMedium!.copyWith(
|
||||||
|
|
|
@ -66,10 +66,11 @@ class HomeScreenState extends State<HomeScreen>
|
||||||
final scale = theme.extension<ScaleScheme>()!;
|
final scale = theme.extension<ScaleScheme>()!;
|
||||||
final scaleConfig = theme.extension<ScaleConfig>()!;
|
final scaleConfig = theme.extension<ScaleConfig>()!;
|
||||||
|
|
||||||
await showWarningWidgetModal(
|
await showAlertWidgetModal(
|
||||||
context: context,
|
context: context,
|
||||||
title: translate('splash.beta_title'),
|
title: translate('splash.beta_title'),
|
||||||
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
|
const Icon(Icons.warning, size: 64),
|
||||||
RichText(
|
RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
|
|
|
@ -129,9 +129,6 @@ Widget buildSettingsPageNotificationPreferences(
|
||||||
// Display Beta Warning
|
// Display Beta Warning
|
||||||
FormBuilderCheckbox(
|
FormBuilderCheckbox(
|
||||||
name: formFieldDisplayBetaWarning,
|
name: formFieldDisplayBetaWarning,
|
||||||
side: BorderSide(color: scale.primaryScale.border, width: 2),
|
|
||||||
checkColor: scale.primaryScale.borderText,
|
|
||||||
activeColor: scale.primaryScale.border,
|
|
||||||
title: Text(translate('settings_page.display_beta_warning'),
|
title: Text(translate('settings_page.display_beta_warning'),
|
||||||
style: textTheme.labelMedium),
|
style: textTheme.labelMedium),
|
||||||
initialValue: notificationsPreference.displayBetaWarning,
|
initialValue: notificationsPreference.displayBetaWarning,
|
||||||
|
@ -147,9 +144,6 @@ Widget buildSettingsPageNotificationPreferences(
|
||||||
// Enable Badge
|
// Enable Badge
|
||||||
FormBuilderCheckbox(
|
FormBuilderCheckbox(
|
||||||
name: formFieldEnableBadge,
|
name: formFieldEnableBadge,
|
||||||
side: BorderSide(color: scale.primaryScale.border, width: 2),
|
|
||||||
checkColor: scale.primaryScale.borderText,
|
|
||||||
activeColor: scale.primaryScale.border,
|
|
||||||
title: Text(translate('settings_page.enable_badge'),
|
title: Text(translate('settings_page.enable_badge'),
|
||||||
style: textTheme.labelMedium),
|
style: textTheme.labelMedium),
|
||||||
initialValue: notificationsPreference.enableBadge,
|
initialValue: notificationsPreference.enableBadge,
|
||||||
|
@ -164,9 +158,6 @@ Widget buildSettingsPageNotificationPreferences(
|
||||||
// Enable Notifications
|
// Enable Notifications
|
||||||
FormBuilderCheckbox(
|
FormBuilderCheckbox(
|
||||||
name: formFieldEnableNotifications,
|
name: formFieldEnableNotifications,
|
||||||
side: BorderSide(color: scale.primaryScale.border, width: 2),
|
|
||||||
checkColor: scale.primaryScale.borderText,
|
|
||||||
activeColor: scale.primaryScale.border,
|
|
||||||
title: Text(translate('settings_page.enable_notifications'),
|
title: Text(translate('settings_page.enable_notifications'),
|
||||||
style: textTheme.labelMedium),
|
style: textTheme.labelMedium),
|
||||||
initialValue: notificationsPreference.enableNotifications,
|
initialValue: notificationsPreference.enableNotifications,
|
||||||
|
|
|
@ -638,7 +638,7 @@ ThemeData radixGenerator(Brightness brightness, RadixThemeColor themeColor) {
|
||||||
useVisualIndicators: false,
|
useVisualIndicators: false,
|
||||||
preferBorders: false,
|
preferBorders: false,
|
||||||
borderRadiusScale: 1,
|
borderRadiusScale: 1,
|
||||||
wallpaperAlpha: wallpaperAlpha(brightness, themeColor),
|
wallpaperOpacity: wallpaperAlpha(brightness, themeColor),
|
||||||
);
|
);
|
||||||
|
|
||||||
final scaleTheme = ScaleTheme(
|
final scaleTheme = ScaleTheme(
|
||||||
|
|
|
@ -50,11 +50,11 @@ class ScaleColor {
|
||||||
Color? subtleBorder,
|
Color? subtleBorder,
|
||||||
Color? border,
|
Color? border,
|
||||||
Color? hoverBorder,
|
Color? hoverBorder,
|
||||||
Color? background,
|
Color? primary,
|
||||||
Color? hoverBackground,
|
Color? hoverPrimary,
|
||||||
Color? subtleText,
|
Color? subtleText,
|
||||||
Color? appText,
|
Color? appText,
|
||||||
Color? foregroundText,
|
Color? primaryText,
|
||||||
Color? borderText,
|
Color? borderText,
|
||||||
Color? dialogBorder,
|
Color? dialogBorder,
|
||||||
Color? dialogBorderText,
|
Color? dialogBorderText,
|
||||||
|
@ -72,11 +72,11 @@ class ScaleColor {
|
||||||
subtleBorder: subtleBorder ?? this.subtleBorder,
|
subtleBorder: subtleBorder ?? this.subtleBorder,
|
||||||
border: border ?? this.border,
|
border: border ?? this.border,
|
||||||
hoverBorder: hoverBorder ?? this.hoverBorder,
|
hoverBorder: hoverBorder ?? this.hoverBorder,
|
||||||
primary: background ?? this.primary,
|
primary: primary ?? this.primary,
|
||||||
hoverPrimary: hoverBackground ?? this.hoverPrimary,
|
hoverPrimary: hoverPrimary ?? this.hoverPrimary,
|
||||||
subtleText: subtleText ?? this.subtleText,
|
subtleText: subtleText ?? this.subtleText,
|
||||||
appText: appText ?? this.appText,
|
appText: appText ?? this.appText,
|
||||||
primaryText: foregroundText ?? this.primaryText,
|
primaryText: primaryText ?? this.primaryText,
|
||||||
borderText: borderText ?? this.borderText,
|
borderText: borderText ?? this.borderText,
|
||||||
dialogBorder: dialogBorder ?? this.dialogBorder,
|
dialogBorder: dialogBorder ?? this.dialogBorder,
|
||||||
dialogBorderText: dialogBorderText ?? this.dialogBorderText,
|
dialogBorderText: dialogBorderText ?? this.dialogBorderText,
|
||||||
|
|
|
@ -68,7 +68,7 @@ extension ScaleCustomDropdownThemeExt on ScaleTheme {
|
||||||
listItemDecoration: null,
|
listItemDecoration: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final disabledDecoration = CustomDropdownDisabledDecoration(
|
const disabledDecoration = CustomDropdownDisabledDecoration(
|
||||||
fillColor: null,
|
fillColor: null,
|
||||||
shadow: null,
|
shadow: null,
|
||||||
suffixIcon: null,
|
suffixIcon: null,
|
||||||
|
|
|
@ -111,27 +111,27 @@ class ScaleConfig extends ThemeExtension<ScaleConfig> {
|
||||||
required this.useVisualIndicators,
|
required this.useVisualIndicators,
|
||||||
required this.preferBorders,
|
required this.preferBorders,
|
||||||
required this.borderRadiusScale,
|
required this.borderRadiusScale,
|
||||||
required double wallpaperAlpha,
|
required this.wallpaperOpacity,
|
||||||
}) : _wallpaperAlpha = wallpaperAlpha;
|
});
|
||||||
|
|
||||||
final bool useVisualIndicators;
|
final bool useVisualIndicators;
|
||||||
final bool preferBorders;
|
final bool preferBorders;
|
||||||
final double borderRadiusScale;
|
final double borderRadiusScale;
|
||||||
final double _wallpaperAlpha;
|
final double wallpaperOpacity;
|
||||||
|
|
||||||
int get wallpaperAlpha => _wallpaperAlpha.toInt();
|
int get wallpaperAlpha => wallpaperOpacity.toInt();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ScaleConfig copyWith(
|
ScaleConfig copyWith(
|
||||||
{bool? useVisualIndicators,
|
{bool? useVisualIndicators,
|
||||||
bool? preferBorders,
|
bool? preferBorders,
|
||||||
double? borderRadiusScale,
|
double? borderRadiusScale,
|
||||||
double? wallpaperAlpha}) =>
|
double? wallpaperOpacity}) =>
|
||||||
ScaleConfig(
|
ScaleConfig(
|
||||||
useVisualIndicators: useVisualIndicators ?? this.useVisualIndicators,
|
useVisualIndicators: useVisualIndicators ?? this.useVisualIndicators,
|
||||||
preferBorders: preferBorders ?? this.preferBorders,
|
preferBorders: preferBorders ?? this.preferBorders,
|
||||||
borderRadiusScale: borderRadiusScale ?? this.borderRadiusScale,
|
borderRadiusScale: borderRadiusScale ?? this.borderRadiusScale,
|
||||||
wallpaperAlpha: wallpaperAlpha ?? this._wallpaperAlpha,
|
wallpaperOpacity: wallpaperOpacity ?? this.wallpaperOpacity,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -145,7 +145,7 @@ class ScaleConfig extends ThemeExtension<ScaleConfig> {
|
||||||
preferBorders: t < .5 ? preferBorders : other.preferBorders,
|
preferBorders: t < .5 ? preferBorders : other.preferBorders,
|
||||||
borderRadiusScale:
|
borderRadiusScale:
|
||||||
lerpDouble(borderRadiusScale, other.borderRadiusScale, t) ?? 1,
|
lerpDouble(borderRadiusScale, other.borderRadiusScale, t) ?? 1,
|
||||||
wallpaperAlpha:
|
wallpaperOpacity:
|
||||||
lerpDouble(_wallpaperAlpha, other._wallpaperAlpha, t) ?? 1);
|
lerpDouble(wallpaperOpacity, other.wallpaperOpacity, t) ?? 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,24 @@ class ScaleTheme extends ThemeExtension<ScaleTheme> {
|
||||||
scheme.primaryScale.borderText, scheme.primaryScale.primary, 0.25);
|
scheme.primaryScale.borderText, scheme.primaryScale.primary, 0.25);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WidgetStateProperty<Color?> checkboxFillColorWidgetStateProperty() =>
|
||||||
|
WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
if (states.contains(WidgetState.disabled)) {
|
||||||
|
return scheme.grayScale.primary.withAlpha(0x7F);
|
||||||
|
} else if (states.contains(WidgetState.pressed)) {
|
||||||
|
return scheme.primaryScale.hoverBorder;
|
||||||
|
} else if (states.contains(WidgetState.hovered)) {
|
||||||
|
return scheme.primaryScale.hoverBorder;
|
||||||
|
} else if (states.contains(WidgetState.focused)) {
|
||||||
|
return scheme.primaryScale.border;
|
||||||
|
}
|
||||||
|
return scheme.primaryScale.border;
|
||||||
|
} else {
|
||||||
|
return Colors.transparent;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// WidgetStateProperty<Color?> elementBackgroundWidgetStateProperty() {
|
// WidgetStateProperty<Color?> elementBackgroundWidgetStateProperty() {
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
@ -140,7 +158,7 @@ class ScaleTheme extends ThemeExtension<ScaleTheme> {
|
||||||
appBarTheme: baseThemeData.appBarTheme.copyWith(
|
appBarTheme: baseThemeData.appBarTheme.copyWith(
|
||||||
backgroundColor: scheme.primaryScale.border,
|
backgroundColor: scheme.primaryScale.border,
|
||||||
foregroundColor: scheme.primaryScale.borderText,
|
foregroundColor: scheme.primaryScale.borderText,
|
||||||
toolbarHeight: 40,
|
toolbarHeight: 48,
|
||||||
),
|
),
|
||||||
bottomSheetTheme: baseThemeData.bottomSheetTheme.copyWith(
|
bottomSheetTheme: baseThemeData.bottomSheetTheme.copyWith(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
@ -150,6 +168,11 @@ class ScaleTheme extends ThemeExtension<ScaleTheme> {
|
||||||
topLeft: Radius.circular(16 * config.borderRadiusScale),
|
topLeft: Radius.circular(16 * config.borderRadiusScale),
|
||||||
topRight: Radius.circular(16 * config.borderRadiusScale)))),
|
topRight: Radius.circular(16 * config.borderRadiusScale)))),
|
||||||
canvasColor: scheme.primaryScale.subtleBackground,
|
canvasColor: scheme.primaryScale.subtleBackground,
|
||||||
|
checkboxTheme: baseThemeData.checkboxTheme.copyWith(
|
||||||
|
side: BorderSide(color: scheme.primaryScale.border, width: 2),
|
||||||
|
checkColor: elementColorWidgetStateProperty(),
|
||||||
|
fillColor: checkboxFillColorWidgetStateProperty(),
|
||||||
|
),
|
||||||
chipTheme: baseThemeData.chipTheme.copyWith(
|
chipTheme: baseThemeData.chipTheme.copyWith(
|
||||||
backgroundColor: scheme.primaryScale.elementBackground,
|
backgroundColor: scheme.primaryScale.elementBackground,
|
||||||
selectedColor: scheme.primaryScale.activeElementBackground,
|
selectedColor: scheme.primaryScale.activeElementBackground,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:change_case/change_case.dart';
|
import 'package:change_case/change_case.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
@ -103,7 +102,7 @@ extension ThemePreferencesExt on ThemePreferences {
|
||||||
useVisualIndicators: true,
|
useVisualIndicators: true,
|
||||||
preferBorders: false,
|
preferBorders: false,
|
||||||
borderRadiusScale: 1,
|
borderRadiusScale: 1,
|
||||||
wallpaperAlpha: 255),
|
wallpaperOpacity: 255),
|
||||||
primaryFront: Colors.black,
|
primaryFront: Colors.black,
|
||||||
primaryBack: Colors.white,
|
primaryBack: Colors.white,
|
||||||
secondaryFront: Colors.black,
|
secondaryFront: Colors.black,
|
||||||
|
@ -123,7 +122,7 @@ extension ThemePreferencesExt on ThemePreferences {
|
||||||
useVisualIndicators: true,
|
useVisualIndicators: true,
|
||||||
preferBorders: true,
|
preferBorders: true,
|
||||||
borderRadiusScale: 0.2,
|
borderRadiusScale: 0.2,
|
||||||
wallpaperAlpha: 208),
|
wallpaperOpacity: 208),
|
||||||
primaryFront: const Color(0xFF000000),
|
primaryFront: const Color(0xFF000000),
|
||||||
primaryBack: const Color(0xFF00FF00),
|
primaryBack: const Color(0xFF00FF00),
|
||||||
secondaryFront: const Color(0xFF000000),
|
secondaryFront: const Color(0xFF000000),
|
||||||
|
@ -141,7 +140,7 @@ extension ThemePreferencesExt on ThemePreferences {
|
||||||
useVisualIndicators: true,
|
useVisualIndicators: true,
|
||||||
preferBorders: true,
|
preferBorders: true,
|
||||||
borderRadiusScale: 0.2,
|
borderRadiusScale: 0.2,
|
||||||
wallpaperAlpha: 192),
|
wallpaperOpacity: 192),
|
||||||
primaryFront: const Color(0xFF000000),
|
primaryFront: const Color(0xFF000000),
|
||||||
primaryBack: const Color(0xFF00FF00),
|
primaryBack: const Color(0xFF00FF00),
|
||||||
secondaryFront: const Color(0xFF000000),
|
secondaryFront: const Color(0xFF000000),
|
||||||
|
|
|
@ -14,16 +14,12 @@ class ScannerErrorWidget extends StatelessWidget {
|
||||||
switch (error.errorCode) {
|
switch (error.errorCode) {
|
||||||
case MobileScannerErrorCode.controllerUninitialized:
|
case MobileScannerErrorCode.controllerUninitialized:
|
||||||
errorMessage = 'Controller not ready.';
|
errorMessage = 'Controller not ready.';
|
||||||
break;
|
|
||||||
case MobileScannerErrorCode.permissionDenied:
|
case MobileScannerErrorCode.permissionDenied:
|
||||||
errorMessage = 'Permission denied';
|
errorMessage = 'Permission denied';
|
||||||
break;
|
|
||||||
case MobileScannerErrorCode.unsupported:
|
case MobileScannerErrorCode.unsupported:
|
||||||
errorMessage = 'Scanning is unsupported on this device';
|
errorMessage = 'Scanning is unsupported on this device';
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
errorMessage = 'Generic Error';
|
errorMessage = 'Generic Error';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
|
|
|
@ -11,6 +11,7 @@ AlertStyle _alertStyle(BuildContext context) {
|
||||||
|
|
||||||
return AlertStyle(
|
return AlertStyle(
|
||||||
animationType: AnimationType.grow,
|
animationType: AnimationType.grow,
|
||||||
|
isCloseButton: false,
|
||||||
//animationDuration: const Duration(milliseconds: 200),
|
//animationDuration: const Duration(milliseconds: 200),
|
||||||
alertBorder: RoundedRectangleBorder(
|
alertBorder: RoundedRectangleBorder(
|
||||||
side: !scaleConfig.useVisualIndicators
|
side: !scaleConfig.useVisualIndicators
|
||||||
|
@ -131,7 +132,7 @@ Future<void> showErrorStacktraceModal(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> showWarningModal(
|
Future<void> showAlertModal(
|
||||||
{required BuildContext context,
|
{required BuildContext context,
|
||||||
required String title,
|
required String title,
|
||||||
required String text}) async {
|
required String text}) async {
|
||||||
|
@ -139,7 +140,7 @@ Future<void> showWarningModal(
|
||||||
context: context,
|
context: context,
|
||||||
style: _alertStyle(context),
|
style: _alertStyle(context),
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
type: AlertType.warning,
|
type: AlertType.none,
|
||||||
title: title,
|
title: title,
|
||||||
desc: text,
|
desc: text,
|
||||||
buttons: [
|
buttons: [
|
||||||
|
@ -161,7 +162,7 @@ Future<void> showWarningModal(
|
||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> showWarningWidgetModal(
|
Future<void> showAlertWidgetModal(
|
||||||
{required BuildContext context,
|
{required BuildContext context,
|
||||||
required String title,
|
required String title,
|
||||||
required Widget child}) async {
|
required Widget child}) async {
|
||||||
|
@ -169,7 +170,7 @@ Future<void> showWarningWidgetModal(
|
||||||
context: context,
|
context: context,
|
||||||
style: _alertStyle(context),
|
style: _alertStyle(context),
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
type: AlertType.warning,
|
type: AlertType.none,
|
||||||
title: title,
|
title: title,
|
||||||
content: child,
|
content: child,
|
||||||
buttons: [
|
buttons: [
|
||||||
|
|
|
@ -15,7 +15,6 @@ Widget buildSettingsPageWallpaperPreferences(
|
||||||
final preferencesRepository = PreferencesRepository.instance;
|
final preferencesRepository = PreferencesRepository.instance;
|
||||||
final themePreferences = preferencesRepository.value.themePreference;
|
final themePreferences = preferencesRepository.value.themePreference;
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final scale = theme.extension<ScaleScheme>()!;
|
|
||||||
final textTheme = theme.textTheme;
|
final textTheme = theme.textTheme;
|
||||||
|
|
||||||
return FormBuilderCheckbox(
|
return FormBuilderCheckbox(
|
||||||
|
@ -23,9 +22,6 @@ Widget buildSettingsPageWallpaperPreferences(
|
||||||
title: Text(translate('settings_page.enable_wallpaper'),
|
title: Text(translate('settings_page.enable_wallpaper'),
|
||||||
style: textTheme.labelMedium),
|
style: textTheme.labelMedium),
|
||||||
initialValue: themePreferences.enableWallpaper,
|
initialValue: themePreferences.enableWallpaper,
|
||||||
side: BorderSide(color: scale.primaryScale.border, width: 2),
|
|
||||||
checkColor: scale.primaryScale.borderText,
|
|
||||||
activeColor: scale.primaryScale.border,
|
|
||||||
onChanged: (value) async {
|
onChanged: (value) async {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final newThemePrefs =
|
final newThemePrefs =
|
||||||
|
|
|
@ -44,13 +44,6 @@ class ProcessorRepository {
|
||||||
|
|
||||||
log.info('Veilid version: $veilidVersion');
|
log.info('Veilid version: $veilidVersion');
|
||||||
|
|
||||||
// HACK: In case of hot restart shut down first
|
|
||||||
try {
|
|
||||||
await Veilid.instance.shutdownVeilidCore();
|
|
||||||
} on Exception {
|
|
||||||
// Do nothing on failure here
|
|
||||||
}
|
|
||||||
|
|
||||||
final updateStream = await Veilid.instance
|
final updateStream = await Veilid.instance
|
||||||
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
|
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
|
||||||
_updateSubscription = updateStream.listen((update) {
|
_updateSubscription = updateStream.listen((update) {
|
||||||
|
|
|
@ -5,13 +5,12 @@
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
// tree, read text, and verify that the values of widget properties are correct.
|
||||||
|
|
||||||
|
import 'package:example/main.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:example/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(const MyApp());
|
await tester.pumpWidget(const MyApp());
|
||||||
|
|
||||||
|
|
|
@ -171,13 +171,13 @@ class DHTLog implements DHTDeleteable<DHTLog> {
|
||||||
|
|
||||||
/// Add a reference to this log
|
/// Add a reference to this log
|
||||||
@override
|
@override
|
||||||
Future<void> ref() async => _mutex.protect(() async {
|
void ref() {
|
||||||
_openCount++;
|
_openCount++;
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Free all resources for the DHTLog
|
/// Free all resources for the DHTLog
|
||||||
@override
|
@override
|
||||||
Future<bool> close() async => _mutex.protect(() async {
|
Future<bool> close() async {
|
||||||
if (_openCount == 0) {
|
if (_openCount == 0) {
|
||||||
throw StateError('already closed');
|
throw StateError('already closed');
|
||||||
}
|
}
|
||||||
|
@ -185,18 +185,17 @@ class DHTLog implements DHTDeleteable<DHTLog> {
|
||||||
if (_openCount != 0) {
|
if (_openCount != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
await _watchController?.close();
|
await _watchController?.close();
|
||||||
_watchController = null;
|
_watchController = null;
|
||||||
await _spine.close();
|
await _spine.close();
|
||||||
return true;
|
return true;
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Free all resources for the DHTLog and delete it from the DHT
|
/// Free all resources for the DHTLog and delete it from the DHT
|
||||||
/// Will wait until the short array is closed to delete it
|
/// Will wait until the short array is closed to delete it
|
||||||
@override
|
@override
|
||||||
Future<void> delete() async {
|
Future<bool> delete() => _spine.delete();
|
||||||
await _spine.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Public API
|
// Public API
|
||||||
|
@ -306,7 +305,6 @@ class DHTLog implements DHTDeleteable<DHTLog> {
|
||||||
|
|
||||||
// Openable
|
// Openable
|
||||||
int _openCount;
|
int _openCount;
|
||||||
final _mutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
|
||||||
|
|
||||||
// Watch mutex to ensure we keep the representation valid
|
// Watch mutex to ensure we keep the representation valid
|
||||||
final Mutex _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
final Mutex _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
||||||
|
|
|
@ -24,13 +24,11 @@ class _DHTLogPosition extends DHTCloseable<DHTShortArray> {
|
||||||
|
|
||||||
/// Add a reference to this log
|
/// Add a reference to this log
|
||||||
@override
|
@override
|
||||||
Future<void> ref() async {
|
void ref() => shortArray.ref();
|
||||||
await shortArray.ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Free all resources for the DHTLogPosition
|
/// Free all resources for the DHTLogPosition
|
||||||
@override
|
@override
|
||||||
Future<bool> close() async => _dhtLogSpine._segmentClosed(_segmentNumber);
|
Future<bool> close() => _dhtLogSpine._segmentClosed(_segmentNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DHTLogSegmentLookup extends Equatable {
|
class _DHTLogSegmentLookup extends Equatable {
|
||||||
|
@ -124,12 +122,8 @@ class _DHTLogSpine {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> delete() async {
|
|
||||||
await _spineMutex.protect(() async {
|
|
||||||
// Will deep delete all segment records as they are children
|
// Will deep delete all segment records as they are children
|
||||||
await _spineRecord.delete();
|
Future<bool> delete() async => _spineMutex.protect(_spineRecord.delete);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<T> operate<T>(Future<T> Function(_DHTLogSpine) closure) async =>
|
Future<T> operate<T>(Future<T> Function(_DHTLogSpine) closure) async =>
|
||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
|
@ -431,7 +425,7 @@ class _DHTLogSpine {
|
||||||
late DHTShortArray shortArray;
|
late DHTShortArray shortArray;
|
||||||
if (openedSegment != null) {
|
if (openedSegment != null) {
|
||||||
// If so, return a ref
|
// If so, return a ref
|
||||||
await openedSegment.ref();
|
openedSegment.ref();
|
||||||
shortArray = openedSegment;
|
shortArray = openedSegment;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise open a segment
|
// Otherwise open a segment
|
||||||
|
@ -453,7 +447,7 @@ class _DHTLogSpine {
|
||||||
// LRU cache the segment number
|
// LRU cache the segment number
|
||||||
if (!_openCache.remove(segmentNumber)) {
|
if (!_openCache.remove(segmentNumber)) {
|
||||||
// If this is new to the cache ref it when it goes in
|
// If this is new to the cache ref it when it goes in
|
||||||
await shortArray.ref();
|
shortArray.ref();
|
||||||
}
|
}
|
||||||
_openCache.add(segmentNumber);
|
_openCache.add(segmentNumber);
|
||||||
if (_openCache.length > _openCacheSize) {
|
if (_openCache.length > _openCacheSize) {
|
||||||
|
|
|
@ -64,13 +64,13 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
|
||||||
|
|
||||||
/// Add a reference to this DHTRecord
|
/// Add a reference to this DHTRecord
|
||||||
@override
|
@override
|
||||||
Future<void> ref() async => _mutex.protect(() async {
|
void ref() {
|
||||||
_openCount++;
|
_openCount++;
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Free all resources for the DHTRecord
|
/// Free all resources for the DHTRecord
|
||||||
@override
|
@override
|
||||||
Future<bool> close() async => _mutex.protect(() async {
|
Future<bool> close() async {
|
||||||
if (_openCount == 0) {
|
if (_openCount == 0) {
|
||||||
throw StateError('already closed');
|
throw StateError('already closed');
|
||||||
}
|
}
|
||||||
|
@ -79,19 +79,20 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await serialFutureClose((this, _sfListen));
|
|
||||||
await _watchController?.close();
|
await _watchController?.close();
|
||||||
_watchController = null;
|
_watchController = null;
|
||||||
|
await serialFutureClose((this, _sfListen));
|
||||||
|
|
||||||
await DHTRecordPool.instance._recordClosed(this);
|
await DHTRecordPool.instance._recordClosed(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Free all resources for the DHTRecord and delete it from the DHT
|
/// Free all resources for the DHTRecord and delete it from the DHT
|
||||||
/// Will wait until the record is closed to delete it
|
/// Returns true if the deletion was processed immediately
|
||||||
|
/// Returns false if the deletion was marked for later
|
||||||
@override
|
@override
|
||||||
Future<void> delete() async => _mutex.protect(() async {
|
Future<bool> delete() async => DHTRecordPool.instance.deleteRecord(key);
|
||||||
await DHTRecordPool.instance.deleteRecord(key);
|
|
||||||
});
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Public API
|
// Public API
|
||||||
|
@ -562,7 +563,6 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
|
||||||
final KeyPair? _writer;
|
final KeyPair? _writer;
|
||||||
final VeilidCrypto _crypto;
|
final VeilidCrypto _crypto;
|
||||||
final String debugName;
|
final String debugName;
|
||||||
final _mutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
|
||||||
int _openCount;
|
int _openCount;
|
||||||
StreamController<DHTRecordWatchChange>? _watchController;
|
StreamController<DHTRecordWatchChange>? _watchController;
|
||||||
_WatchState? _watchState;
|
_WatchState? _watchState;
|
||||||
|
|
|
@ -479,10 +479,9 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
||||||
// Called when a DHTRecord is closed
|
// Called when a DHTRecord is closed
|
||||||
// Cleans up the opened record housekeeping and processes any late deletions
|
// Cleans up the opened record housekeeping and processes any late deletions
|
||||||
Future<void> _recordClosed(DHTRecord record) async {
|
Future<void> _recordClosed(DHTRecord record) async {
|
||||||
await _recordTagLock.protect(record.key,
|
|
||||||
closure: () => _mutex.protect(() async {
|
|
||||||
final key = record.key;
|
final key = record.key;
|
||||||
|
await _recordTagLock.protect(key, closure: () async {
|
||||||
|
await _mutex.protect(() async {
|
||||||
log('closeDHTRecord: debugName=${record.debugName} key=$key');
|
log('closeDHTRecord: debugName=${record.debugName} key=$key');
|
||||||
|
|
||||||
final openedRecordInfo = _opened[key];
|
final openedRecordInfo = _opened[key];
|
||||||
|
@ -490,14 +489,19 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
||||||
!openedRecordInfo.records.remove(record)) {
|
!openedRecordInfo.records.remove(record)) {
|
||||||
throw StateError('record already closed');
|
throw StateError('record already closed');
|
||||||
}
|
}
|
||||||
if (openedRecordInfo.records.isEmpty) {
|
if (openedRecordInfo.records.isNotEmpty) {
|
||||||
await _watchStateProcessors.remove(key);
|
return;
|
||||||
await _routingContext.closeDHTRecord(key);
|
|
||||||
_opened.remove(key);
|
|
||||||
|
|
||||||
await _checkForLateDeletesInner(key);
|
|
||||||
}
|
}
|
||||||
}));
|
_opened.remove(key);
|
||||||
|
await _routingContext.closeDHTRecord(key);
|
||||||
|
await _checkForLateDeletesInner(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
// This happens after the mutex is released
|
||||||
|
// because the record has already been removed from _opened
|
||||||
|
// which means that updates to the state processor won't happen
|
||||||
|
await _watchStateProcessors.remove(key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if this key can finally be deleted
|
// Check to see if this key can finally be deleted
|
||||||
|
@ -929,11 +933,9 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ticker to check watch state change requests
|
/// Ticker to check watch state change requests
|
||||||
Future<void> tick() async {
|
Future<void> tick() async => _mutex.protect(() async {
|
||||||
final now = veilid.now();
|
|
||||||
|
|
||||||
await _mutex.protect(() async {
|
|
||||||
// See if any opened records need watch state changes
|
// See if any opened records need watch state changes
|
||||||
|
final now = veilid.now();
|
||||||
for (final kv in _opened.entries) {
|
for (final kv in _opened.entries) {
|
||||||
final openedRecordKey = kv.key;
|
final openedRecordKey = kv.key;
|
||||||
final openedRecordInfo = kv.value;
|
final openedRecordInfo = kv.value;
|
||||||
|
@ -962,7 +964,6 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// AsyncTableDBBacked
|
// AsyncTableDBBacked
|
||||||
|
|
|
@ -148,13 +148,13 @@ class DHTShortArray implements DHTDeleteable<DHTShortArray> {
|
||||||
|
|
||||||
/// Add a reference to this shortarray
|
/// Add a reference to this shortarray
|
||||||
@override
|
@override
|
||||||
Future<void> ref() async => _mutex.protect(() async {
|
void ref() {
|
||||||
_openCount++;
|
_openCount++;
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Free all resources for the DHTShortArray
|
/// Free all resources for the DHTShortArray
|
||||||
@override
|
@override
|
||||||
Future<bool> close() async => _mutex.protect(() async {
|
Future<bool> close() async {
|
||||||
if (_openCount == 0) {
|
if (_openCount == 0) {
|
||||||
throw StateError('already closed');
|
throw StateError('already closed');
|
||||||
}
|
}
|
||||||
|
@ -167,14 +167,13 @@ class DHTShortArray implements DHTDeleteable<DHTShortArray> {
|
||||||
_watchController = null;
|
_watchController = null;
|
||||||
await _head.close();
|
await _head.close();
|
||||||
return true;
|
return true;
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Free all resources for the DHTShortArray and delete it from the DHT
|
/// Free all resources for the DHTShortArray and delete it from the DHT
|
||||||
/// Will wait until the short array is closed to delete it
|
/// Returns true if the deletion was processed immediately
|
||||||
|
/// Returns false if the deletion was marked for later
|
||||||
@override
|
@override
|
||||||
Future<void> delete() async {
|
Future<bool> delete() async => _head.delete();
|
||||||
await _head.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Public API
|
// Public API
|
||||||
|
@ -289,7 +288,6 @@ class DHTShortArray implements DHTDeleteable<DHTShortArray> {
|
||||||
|
|
||||||
// Openable
|
// Openable
|
||||||
int _openCount;
|
int _openCount;
|
||||||
final _mutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
|
||||||
|
|
||||||
// Watch mutex to ensure we keep the representation valid
|
// Watch mutex to ensure we keep the representation valid
|
||||||
final Mutex _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
final Mutex _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
import '../../../veilid_support.dart';
|
import '../../../veilid_support.dart';
|
||||||
import '../interfaces/refreshable_cubit.dart';
|
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class DHTShortArrayElementState<T> extends Equatable {
|
class DHTShortArrayElementState<T> extends Equatable {
|
||||||
|
|
|
@ -65,12 +65,9 @@ class _DHTShortArrayHead {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> delete() async {
|
/// Returns true if the deletion was processed immediately
|
||||||
await _headMutex.protect(() async {
|
/// Returns false if the deletion was marked for later
|
||||||
// Will deep delete all linked records as they are children
|
Future<bool> delete() => _headMutex.protect(_headRecord.delete);
|
||||||
await _headRecord.delete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<T> operate<T>(Future<T> Function(_DHTShortArrayHead) closure) async =>
|
Future<T> operate<T>(Future<T> Function(_DHTShortArrayHead) closure) async =>
|
||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
|
|
|
@ -40,7 +40,7 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw DHTExceptionOutdated();
|
throw const DHTExceptionOutdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw DHTExceptionOutdated();
|
throw const DHTExceptionOutdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import 'package:meta/meta.dart';
|
||||||
|
|
||||||
abstract class DHTCloseable<D> {
|
abstract class DHTCloseable<D> {
|
||||||
// Public interface
|
// Public interface
|
||||||
Future<void> ref();
|
void ref();
|
||||||
Future<bool> close();
|
Future<bool> close();
|
||||||
|
|
||||||
// Internal implementation
|
// Internal implementation
|
||||||
|
@ -15,7 +15,9 @@ abstract class DHTCloseable<D> {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class DHTDeleteable<D> extends DHTCloseable<D> {
|
abstract class DHTDeleteable<D> extends DHTCloseable<D> {
|
||||||
Future<void> delete();
|
/// Returns true if the deletion was processed immediately
|
||||||
|
/// Returns false if the deletion was marked for later
|
||||||
|
Future<bool> delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DHTCloseableExt<D> on DHTCloseable<D> {
|
extension DHTCloseableExt<D> on DHTCloseable<D> {
|
||||||
|
|
|
@ -156,10 +156,9 @@ packages:
|
||||||
bloc_advanced_tools:
|
bloc_advanced_tools:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: bloc_advanced_tools
|
path: "../bloc_advanced_tools"
|
||||||
sha256: "977f3c7e3f9a19aec2f2c734ae99c8f0799c1b78f9fd7e4dce91a2dbf773e11b"
|
relative: true
|
||||||
url: "https://pub.dev"
|
source: path
|
||||||
source: hosted
|
|
||||||
version: "0.1.9"
|
version: "0.1.9"
|
||||||
blurry_modal_progress_hud:
|
blurry_modal_progress_hud:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
|
|
|
@ -111,11 +111,11 @@ dependencies:
|
||||||
xterm: ^4.0.0
|
xterm: ^4.0.0
|
||||||
zxing2: ^0.2.3
|
zxing2: ^0.2.3
|
||||||
|
|
||||||
# dependency_overrides:
|
dependency_overrides:
|
||||||
# async_tools:
|
# async_tools:
|
||||||
# path: ../dart_async_tools
|
# path: ../dart_async_tools
|
||||||
# bloc_advanced_tools:
|
bloc_advanced_tools:
|
||||||
# path: ../bloc_advanced_tools
|
path: ../bloc_advanced_tools
|
||||||
# searchable_listview:
|
# searchable_listview:
|
||||||
# path: ../Searchable-Listview
|
# path: ../Searchable-Listview
|
||||||
# flutter_chat_ui:
|
# flutter_chat_ui:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue