Fix bugs
This commit is contained in:
@@ -31,7 +31,7 @@ class AboutPage extends HookConsumerWidget {
|
||||
canIgnore: false,
|
||||
).show(context);
|
||||
case AppUpdateStateError(:final error):
|
||||
return CustomToast.error(t.printError(error)).show(context);
|
||||
return CustomToast.error(t.presentShortError(error)).show(context);
|
||||
case AppUpdateStateNotAvailable():
|
||||
return CustomToast.success(t.appUpdate.notAvailableMsg)
|
||||
.show(context);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:dartx/dartx.dart';
|
||||
import 'package:hiddify/core/prefs/general_prefs.dart';
|
||||
import 'package:hiddify/features/common/app_update_notifier.dart';
|
||||
import 'package:hiddify/features/common/connectivity/connectivity_controller.dart';
|
||||
@@ -20,8 +19,7 @@ void commonControllers(CommonControllersRef ref) {
|
||||
introCompletedProvider,
|
||||
(_, completed) async {
|
||||
if (completed) {
|
||||
await Future.delayed(5.seconds)
|
||||
.then((_) async => ref.read(cronServiceProvider).startScheduler());
|
||||
await ref.read(cronServiceProvider).startScheduler();
|
||||
}
|
||||
},
|
||||
fireImmediately: true,
|
||||
|
||||
@@ -7,23 +7,30 @@ import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
// TODO add release notes
|
||||
class NewVersionDialog extends HookConsumerWidget {
|
||||
const NewVersionDialog(
|
||||
class NewVersionDialog extends HookConsumerWidget with PresLogger {
|
||||
NewVersionDialog(
|
||||
this.currentVersion,
|
||||
this.newVersion, {
|
||||
super.key,
|
||||
// super.key,
|
||||
this.canIgnore = true,
|
||||
});
|
||||
}) : super(key: _dialogKey);
|
||||
|
||||
final String currentVersion;
|
||||
final RemoteVersionInfo newVersion;
|
||||
final bool canIgnore;
|
||||
|
||||
Future<void> show(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
);
|
||||
static final _dialogKey = GlobalKey(debugLabel: 'new version dialog');
|
||||
|
||||
Future<void> show(BuildContext context) async {
|
||||
if (_dialogKey.currentContext == null) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
builder: (context) => this,
|
||||
);
|
||||
} else {
|
||||
loggy.warning("new version dialog is already open");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -32,7 +32,7 @@ class ProfileTile extends HookConsumerWidget {
|
||||
|
||||
final selectActiveMutation = useMutation(
|
||||
initialOnFailure: (err) {
|
||||
CustomToast.error(t.printError(err)).show(context);
|
||||
CustomToast.error(t.presentShortError(err)).show(context);
|
||||
},
|
||||
initialOnSuccess: () {
|
||||
if (context.mounted) context.pop();
|
||||
|
||||
@@ -68,7 +68,7 @@ class HomePage extends HookConsumerWidget {
|
||||
_ => const EmptyProfilesHomeBody(),
|
||||
},
|
||||
AsyncError(:final error) =>
|
||||
SliverErrorBodyPlaceholder(t.printError(error)),
|
||||
SliverErrorBodyPlaceholder(t.presentShortError(error)),
|
||||
_ => const SliverToBoxAdapter(),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -69,8 +69,16 @@ class IntroPage extends HookConsumerWidget with PresLogger {
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (!ref.read(enableAnalyticsProvider)) {
|
||||
loggy.debug("disabling analytics per user request");
|
||||
await Sentry.close();
|
||||
loggy.info("disabling analytics per user request");
|
||||
try {
|
||||
await Sentry.close();
|
||||
} catch (error, stackTrace) {
|
||||
loggy.warning(
|
||||
"could not disable analytics",
|
||||
error,
|
||||
stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
await ref
|
||||
.read(introCompletedProvider.notifier)
|
||||
|
||||
@@ -138,7 +138,7 @@ class LogsPage extends HookConsumerWidget with PresLogger {
|
||||
NestedTabAppBar(
|
||||
title: Text(t.logs.pageTitle),
|
||||
),
|
||||
SliverErrorBodyPlaceholder(t.printError(error)),
|
||||
SliverErrorBodyPlaceholder(t.presentShortError(error)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -29,7 +29,15 @@ class ProfileDetailPage extends HookConsumerWidget with PresLogger {
|
||||
if (asyncSave case AsyncData(value: final save)) {
|
||||
switch (save) {
|
||||
case MutationFailure(:final failure):
|
||||
CustomAlertDialog.fromErr(t.presentError(failure)).show(context);
|
||||
final String action;
|
||||
if (ref.read(provider) case AsyncData(value: final data)
|
||||
when data.isEditing) {
|
||||
action = t.profile.save.failureMsg;
|
||||
} else {
|
||||
action = t.profile.add.failureMsg;
|
||||
}
|
||||
CustomAlertDialog.fromErr(t.presentError(failure, action: action))
|
||||
.show(context);
|
||||
case MutationSuccess():
|
||||
CustomToast.success(t.profile.save.successMsg).show(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
@@ -62,7 +70,7 @@ class ProfileDetailPage extends HookConsumerWidget with PresLogger {
|
||||
if (asyncDelete case AsyncData(value: final delete)) {
|
||||
switch (delete) {
|
||||
case MutationFailure(:final failure):
|
||||
CustomToast.error(t.printError(failure)).show(context);
|
||||
CustomToast.error(t.presentShortError(failure)).show(context);
|
||||
case MutationSuccess():
|
||||
CustomToast.success(t.profile.delete.successMsg).show(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
@@ -261,7 +269,7 @@ class ProfileDetailPage extends HookConsumerWidget with PresLogger {
|
||||
title: Text(t.profile.detailsPageTitle),
|
||||
pinned: true,
|
||||
),
|
||||
SliverErrorBodyPlaceholder(t.printError(error)),
|
||||
SliverErrorBodyPlaceholder(t.presentShortError(error)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,9 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
t.failure.profiles.invalidUrl,
|
||||
).show(context);
|
||||
} else {
|
||||
CustomAlertDialog.fromErr(t.presentError(err)).show(context);
|
||||
CustomAlertDialog.fromErr(
|
||||
t.presentError(err, action: t.profile.add.failureMsg),
|
||||
).show(context);
|
||||
}
|
||||
},
|
||||
initialOnSuccess: () {
|
||||
|
||||
@@ -37,7 +37,7 @@ class ProfilesModal extends HookConsumerWidget {
|
||||
itemCount: profiles.length,
|
||||
),
|
||||
AsyncError(:final error) => SliverErrorBodyPlaceholder(
|
||||
t.printError(error),
|
||||
t.presentShortError(error),
|
||||
),
|
||||
AsyncLoading() => const SliverLoadingBodyPlaceholder(),
|
||||
_ => const SliverToBoxAdapter(),
|
||||
|
||||
@@ -20,7 +20,7 @@ class ProxiesPage extends HookConsumerWidget with PresLogger {
|
||||
|
||||
final selectActiveProxyMutation = useMutation(
|
||||
initialOnFailure: (error) =>
|
||||
CustomToast.error(t.printError(error)).show(context),
|
||||
CustomToast.error(t.presentShortError(error)).show(context),
|
||||
);
|
||||
|
||||
switch (asyncProxies) {
|
||||
@@ -144,7 +144,7 @@ class ProxiesPage extends HookConsumerWidget with PresLogger {
|
||||
title: Text(t.proxies.pageTitle),
|
||||
),
|
||||
SliverErrorBodyPlaceholder(
|
||||
t.printError(error),
|
||||
t.presentShortError(error),
|
||||
icon: null,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user