mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-07 23:27:49 +00:00
Bug fixes
This commit is contained in:
parent
51b8a6b610
commit
a666d109d9
8 changed files with 54 additions and 20 deletions
|
@ -5,6 +5,15 @@ import 'package:url_launcher/url_launcher.dart' as url_launcher;
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
||||||
void openUrl(String url) async {
|
void openUrl(String url) async {
|
||||||
|
if (!(url.startsWith("http") || url.startsWith("https"))) {
|
||||||
|
try {
|
||||||
|
url_launcher.launchUrl(Uri.parse(url));
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
Sentry.captureException(e, stackTrace: stackTrace);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Platform.isAndroid || Platform.isIOS) {
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
try {
|
try {
|
||||||
await flutter_custom_tabs.launchUrl(
|
await flutter_custom_tabs.launchUrl(
|
||||||
|
@ -20,6 +29,7 @@ void openUrl(String url) async {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
|
url_launcher.launchUrl(Uri.parse(url));
|
||||||
Sentry.captureException(e, stackTrace: stackTrace);
|
Sentry.captureException(e, stackTrace: stackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,11 +168,22 @@ void main() async {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.message?.formatted.contains("HttpException") == true) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event.message?.formatted.contains("Unexpected character") ?? false ||
|
event.message?.formatted.contains("Unexpected character") ?? false ||
|
||||||
(event.throwable != null && event.throwable!.toString().contains("Unexpected character"))
|
(event.throwable != null && event.throwable!.toString().contains("Unexpected character"))
|
||||||
) {
|
) {
|
||||||
return null; // Exclude this event
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
event.message?.formatted.contains("Unexpected end of input") ?? false ||
|
||||||
|
(event.throwable != null && event.throwable!.toString().contains("Unexpected end of input"))
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
|
|
|
@ -43,9 +43,9 @@ class DnsStatistics {
|
||||||
|
|
||||||
factory DnsStatistics.fromJson(Map<String, dynamic> json) => DnsStatistics(
|
factory DnsStatistics.fromJson(Map<String, dynamic> json) => DnsStatistics(
|
||||||
timeUnits: json["time_units"],
|
timeUnits: json["time_units"],
|
||||||
topQueriedDomains: List<Map<String, int>>.from(json["top_queried_domains"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))),
|
topQueriedDomains: json["top_queried_domains"] != null ? List<Map<String, int>>.from(json["top_queried_domains"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))) : [],
|
||||||
topClients: List<Map<String, int>>.from(json["top_clients"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))),
|
topClients: json["top_clients"] != null ? List<Map<String, int>>.from(json["top_clients"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))) : [],
|
||||||
topBlockedDomains: List<Map<String, int>>.from(json["top_blocked_domains"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))),
|
topBlockedDomains: json["top_blocked_domains"] != null ? List<Map<String, int>>.from(json["top_blocked_domains"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))): [],
|
||||||
topUpstreamResponses: json["top_upstreams_responses"] != null ? List<Map<String, int>>.from(json["top_upstreams_responses"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))) : null,
|
topUpstreamResponses: json["top_upstreams_responses"] != null ? List<Map<String, int>>.from(json["top_upstreams_responses"].map((x) => Map.from(x).map((k, v) => MapEntry<String, int>(k, v)))) : null,
|
||||||
topUpstreamsAvgTime: json["top_upstreams_avg_time"] != null ? List<Map<String, double>>.from(json["top_upstreams_avg_time"].map((x) => Map.from(x).map((k, v) => MapEntry<String, double>(k, v)))) : null,
|
topUpstreamsAvgTime: json["top_upstreams_avg_time"] != null ? List<Map<String, double>>.from(json["top_upstreams_avg_time"].map((x) => Map.from(x).map((k, v) => MapEntry<String, double>(k, v)))) : null,
|
||||||
dnsQueries: List<int>.from(json["dns_queries"].map((x) => x)),
|
dnsQueries: List<int>.from(json["dns_queries"].map((x) => x)),
|
||||||
|
|
|
@ -25,11 +25,15 @@ class ClientsFab extends StatelessWidget {
|
||||||
final width = MediaQuery.of(context).size.width;
|
final width = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
void confirmAddClient(Client client) async {
|
void confirmAddClient(Client client) async {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
ProcessModal processModal = ProcessModal();
|
ProcessModal processModal = ProcessModal();
|
||||||
processModal.open(AppLocalizations.of(context)!.addingClient);
|
processModal.open(AppLocalizations.of(context)!.addingClient);
|
||||||
|
|
||||||
final result = await clientsProvider.addClient(client);
|
final result = await clientsProvider.addClient(client);
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
processModal.close();
|
processModal.close();
|
||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
|
|
|
@ -33,6 +33,8 @@ class AddFiltersButton extends StatelessWidget {
|
||||||
final width = MediaQuery.of(context).size.width;
|
final width = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
void confirmAddRule(String rule) async {
|
void confirmAddRule(String rule) async {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
ProcessModal processModal = ProcessModal();
|
ProcessModal processModal = ProcessModal();
|
||||||
processModal.open(AppLocalizations.of(context)!.addingRule);
|
processModal.open(AppLocalizations.of(context)!.addingRule);
|
||||||
|
|
||||||
|
@ -58,6 +60,8 @@ class AddFiltersButton extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void confirmEditCustomRules(List<String> rules) async {
|
void confirmEditCustomRules(List<String> rules) async {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
ProcessModal processModal = ProcessModal();
|
ProcessModal processModal = ProcessModal();
|
||||||
processModal.open(AppLocalizations.of(context)!.savingCustomRules);
|
processModal.open(AppLocalizations.of(context)!.savingCustomRules);
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,8 @@ class LogTile extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockUnblockRuleClient() async {
|
void blockUnblockRuleClient() async {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
ProcessModal processModal = ProcessModal();
|
ProcessModal processModal = ProcessModal();
|
||||||
processModal.open(AppLocalizations.of(context)!.addingRule);
|
processModal.open(AppLocalizations.of(context)!.addingRule);
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ class LogsListAppBar extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void openLiveLogsScreen() {
|
void openLiveLogsScreen() {
|
||||||
|
if (!context.mounted) return;
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => MultiProvider(
|
builder: (context) => MultiProvider(
|
||||||
|
|
|
@ -175,6 +175,8 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
final ApiClientV2 apiClient2 = ApiClientV2(server: serverObj);
|
final ApiClientV2 apiClient2 = ApiClientV2(server: serverObj);
|
||||||
final serverStatus = await apiClient2.getServerStatus();
|
final serverStatus = await apiClient2.getServerStatus();
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
// If something goes wrong when fetching server status
|
// If something goes wrong when fetching server status
|
||||||
if (serverStatus.successful == false) {
|
if (serverStatus.successful == false) {
|
||||||
statusProvider.setServerStatusLoad(LoadStatus.error);
|
statusProvider.setServerStatusLoad(LoadStatus.error);
|
||||||
|
@ -203,16 +205,16 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
|
|
||||||
final serverCreated = await serversProvider.createServer(serverObj);
|
final serverCreated = await serversProvider.createServer(serverObj);
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
// If something goes wrong when saving the connection on the db
|
// If something goes wrong when saving the connection on the db
|
||||||
if (serverCreated != null) {
|
if (serverCreated != null) {
|
||||||
if (mounted) setState(() => isConnecting = false);
|
setState(() => isConnecting = false);
|
||||||
if (mounted) {
|
showSnackbar(
|
||||||
showSnackbar(
|
appConfigProvider: appConfigProvider,
|
||||||
appConfigProvider: appConfigProvider,
|
label: AppLocalizations.of(context)!.connectionNotCreated,
|
||||||
label: AppLocalizations.of(context)!.connectionNotCreated,
|
color: Colors.red
|
||||||
color: Colors.red
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,9 +298,11 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
|
|
||||||
final serverSaved = await serversProvider.editServer(serverObj);
|
final serverSaved = await serversProvider.editServer(serverObj);
|
||||||
|
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
// If something goes wrong when saving the connection on the db
|
// If something goes wrong when saving the connection on the db
|
||||||
if (serverSaved != null) {
|
if (serverSaved != null) {
|
||||||
if (mounted) setState(() => isConnecting = false);
|
setState(() => isConnecting = false);
|
||||||
appConfigProvider.addLog(
|
appConfigProvider.addLog(
|
||||||
AppLog(
|
AppLog(
|
||||||
type: 'save_connection_db',
|
type: 'save_connection_db',
|
||||||
|
@ -306,13 +310,11 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
message: serverSaved.toString()
|
message: serverSaved.toString()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (mounted) {
|
showSnackbar(
|
||||||
showSnackbar(
|
appConfigProvider: appConfigProvider,
|
||||||
appConfigProvider: appConfigProvider,
|
label: AppLocalizations.of(context)!.connectionNotCreated,
|
||||||
label: AppLocalizations.of(context)!.connectionNotCreated,
|
color: Colors.red
|
||||||
color: Colors.red
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue