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