Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
JGeek00 committed Sep 12, 2024
2 parents 6eb1d73 + 0d0321a commit 9096367
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- name: Decode .env
run: echo "${{ secrets.ENV }}" | base64 --decode > .env
- name: Read pubspec.yaml
uses: adore-me/read-yaml@v1.0.0
uses: JGeek00/read-yaml-files@2.0.0
id: read_pubspec
with:
file: './pubspec.yaml'
file: './pubspec.yaml' # File to read from
key-path: '["version"]'
- name: Save version on env variable
id: save_version
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Decode .env
run: echo "${{ secrets.ENV }}" | base64 --decode > .env
- name: Read pubspec.yaml
uses: jbutcher5/read-yaml@1.6
uses: JGeek00/read-yaml-files@2.0.0
id: read_pubspec
with:
file: './pubspec.yaml' # File to read from
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Decode .env
run: echo "${{ secrets.ENV }}" | base64 --decode > .env
- name: Read pubspec.yaml
uses: jbutcher5/read-yaml@1.6
uses: JGeek00/read-yaml-files@2.0.0
id: read_pubspec
with:
file: './pubspec.yaml'
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
- name: Decode .env
run: echo "${{ secrets.ENV }}" | base64 --decode > .env
- name: Read pubspec.yaml
uses: jbutcher5/read-yaml@1.6
uses: JGeek00/read-yaml-files@2.0.0
id: read_pubspec
with:
file: './pubspec.yaml'
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
run: |
[IO.File]::WriteAllBytes('.env', [Convert]::FromBase64String('${{ secrets.ENV }}'))
- name: Read pubspec.yaml
uses: jbutcher5/read-yaml@1.6
uses: JGeek00/read-yaml-files@2.0.0
id: read_pubspec
with:
file: './pubspec.yaml'
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
"editor.formatOnSave": false,
"editor.formatOnPaste": false,
"editor.formatOnType": false
}
},
"cSpell.ignorePaths": [
"/pubspec.yaml",
"/.github/workflows"
]
}
100 changes: 50 additions & 50 deletions lib/functions/check_app_updates.dart
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import 'dart:io';
// import 'dart:io';

import 'package:install_referrer/install_referrer.dart';
// import 'package:install_referrer/install_referrer.dart';

import 'package:adguard_home_manager/functions/compare_versions.dart';
import 'package:adguard_home_manager/services/external_requests.dart';
import 'package:adguard_home_manager/models/github_release.dart';
// import 'package:adguard_home_manager/functions/compare_versions.dart';
// import 'package:adguard_home_manager/services/external_requests.dart';
// import 'package:adguard_home_manager/models/github_release.dart';

Future<GitHubRelease?> checkAppUpdates({
required String currentBuildNumber,
required void Function(GitHubRelease?) setUpdateAvailable,
required InstallationAppReferrer? installationSource,
required bool isBeta
}) async {
var result = isBeta
? await ExternalRequests.getReleasesGitHub()
: await ExternalRequests.getReleaseData();
// Future<GitHubRelease?> checkAppUpdates({
// required String currentBuildNumber,
// required void Function(GitHubRelease?) setUpdateAvailable,
// required InstallationAppReferrer? installationSource,
// required bool isBeta
// }) async {
// var result = isBeta
// ? await ExternalRequests.getReleasesGitHub()
// : await ExternalRequests.getReleaseData();

if (result.successful == true) {
late GitHubRelease gitHubRelease;
if (isBeta) {
gitHubRelease = (result.content as List<GitHubRelease>).firstWhere((r) => r.prerelease == true);
}
else {
gitHubRelease = result.content as GitHubRelease;
}
// if (result.successful == true) {
// late GitHubRelease gitHubRelease;
// if (isBeta) {
// gitHubRelease = (result.content as List<GitHubRelease>).firstWhere((r) => r.prerelease == true);
// }
// else {
// gitHubRelease = result.content as GitHubRelease;
// }

final update = gitHubUpdateExists(
currentBuildNumber: currentBuildNumber,
gitHubRelease: gitHubRelease,
isBeta: isBeta
);
// final update = gitHubUpdateExists(
// currentBuildNumber: currentBuildNumber,
// gitHubRelease: gitHubRelease,
// isBeta: isBeta
// );

if (update == true) {
setUpdateAvailable(gitHubRelease);
// if (update == true) {
// setUpdateAvailable(gitHubRelease);

if (Platform.isAndroid) {
if (installationSource == InstallationAppReferrer.androidManually) {
return gitHubRelease;
}
else {
return null;
}
}
else if (Platform.isIOS) {
return null;
}
else {
return gitHubRelease;
}
}
else {
setUpdateAvailable(null);
}
}
return null;
}
// if (Platform.isAndroid) {
// if (installationSource == InstallationAppReferrer.androidManually) {
// return gitHubRelease;
// }
// else {
// return null;
// }
// }
// else if (Platform.isIOS) {
// return null;
// }
// else {
// return gitHubRelease;
// }
// }
// else {
// setUpdateAvailable(null);
// }
// }
// return null;
// }
20 changes: 14 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:install_referrer/install_referrer.dart';
import 'package:provider/provider.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:dynamic_color/dynamic_color.dart';
Expand Down Expand Up @@ -79,11 +78,6 @@ void main() async {
HttpOverrides.global = MyHttpOverrides();
}

if (Platform.isAndroid || Platform.isIOS) {
InstallationAppReferrer installationSource = await InstallReferrer.referrer;
appConfigProvider.setInstallationSource(installationSource);
}

final dbData = await loadDb();
serversProvider.setDbInstance(dbData['dbInstance']);
serversProvider.saveFromDb(dbData['servers']);
Expand Down Expand Up @@ -169,6 +163,20 @@ void main() async {
(options) {
options.dsn = dotenv.env['SENTRY_DSN'];
options.sendDefaultPii = false;
options.beforeSend = (event, hint) {
if (event.throwable is HttpException) {
return null;
}

if (
event.message?.formatted.contains("Unexpected character") ?? false ||
(event.throwable != null && event.throwable!.toString().contains("Unexpected character"))
) {
return null; // Exclude this event
}

return event;
};
},
appRunner: () => startApp()
);
Expand Down
2 changes: 1 addition & 1 deletion lib/models/dns_statistics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DnsStatistics dnsStatisticsFromJson(String str) => DnsStatistics.fromJson(json.d
String dnsStatisticsToJson(DnsStatistics data) => json.encode(data.toJson());

class DnsStatistics {
final String timeUnits;
final String? timeUnits;
final List<Map<String, int>> topQueriedDomains;
final List<Map<String, int>> topClients;
final List<Map<String, int>> topBlockedDomains;
Expand Down
28 changes: 17 additions & 11 deletions lib/providers/dns_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,26 @@ class DnsProvider with ChangeNotifier {
final result = await _serversProvider!.apiClient2!.setDnsConfig(
data: value
);

void updateValue(dynamic parameter, dynamic value) {
if (value != null) {
parameter = value;
}
}

if (result.successful == true) {
DnsInfo data = dnsInfo!;
data.ratelimit = value['ratelimit'];
data.ednsCsEnabled = value['edns_cs_enabled'];
data.dnssecEnabled = value['dnssec_enabled'];
data.disableIpv6 = value['disable_ipv6'];
data.blockingMode = value['blocking_mode'];
data.blockingIpv4 = value['blocking_ipv4'];
data.blockingIpv6 = value['blocking_ipv6'];
data.blockedResponseTtl = value['blocked_response_ttl'];
data.ratelimitSubnetLenIpv4 = value['ratelimit_subnet_len_ipv4'];
data.ratelimitSubnetLenIpv6 = value['ratelimit_subnet_len_ipv6'];
data.ratelimitWhitelist = value['ratelimit_whitelist'];
updateValue(data.ratelimit, value['ratelimit']);
updateValue(data.ednsCsEnabled, value['edns_cs_enabled']);
updateValue(data.dnssecEnabled, value['dnssec_enabled']);
updateValue(data.disableIpv6, value['disable_ipv6']);
updateValue(data.blockingMode, value['blocking_mode']);
updateValue(data.blockingIpv4, value['blocking_ipv4']);
updateValue(data.blockingIpv6, value['blocking_ipv6']);
updateValue(data.blockedResponseTtl, value['blocked_response_ttl']);
updateValue(data.ratelimitSubnetLenIpv4, value['ratelimit_subnet_len_ipv4']);
updateValue(data.ratelimitSubnetLenIpv6, value['ratelimit_subnet_len_ipv6']);
updateValue(data.ratelimitWhitelist, value['ratelimit_whitelist']);
setDnsInfoData(data);
return result;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/filters/add_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ class AddFiltersButton extends StatelessWidget {
}

void confirmAddList({required String name, required String url, required String type}) async {
if (!context.mounted) return;

ProcessModal processModal = ProcessModal();
processModal.open(AppLocalizations.of(context)!.addingList);

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/filters/custom_rules_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class _CustomRulesListState extends State<CustomRulesList> {
TextButton.icon(
onPressed: () async {
final result = await filteringProvider.fetchFilters();
if (result == false) {
if (result == false && context.mounted) {
showSnackbar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.errorLoadFilters,
Expand Down
1 change: 1 addition & 0 deletions lib/screens/home/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class HomeAppBar extends StatelessWidget {

void navigateServers() {
Future.delayed(const Duration(milliseconds: 0), (() {
if (!context.mounted) return;
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const Servers())
);
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/logs/filters/clients_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _ClientsModalState extends State<ClientsModal> {

void searchAddedClient(_ClientLog client) {
final notIps = client.ids?.where((e) => isIpAddress(e) == false).toList();
if (notIps == null) return;
if (notIps == null || notIps.isEmpty) return;
logsProvider.setSearchText('"${notIps[0]}"');
Navigator.of(context).pop();
}
Expand Down
4 changes: 4 additions & 0 deletions lib/screens/logs/log_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class LogTile extends StatelessWidget {
}

void blockUnblock({required String domain, required String newStatus}) async {
if (!context.mounted) return;

final ProcessModal processModal = ProcessModal();
processModal.open(AppLocalizations.of(context)!.savingUserFilters);

Expand Down Expand Up @@ -124,6 +126,8 @@ class LogTile extends StatelessWidget {
}

void confirmAddClient(Client client) async {
if (!context.mounted) return;

ProcessModal processModal = ProcessModal();
processModal.open(AppLocalizations.of(context)!.addingClient);

Expand Down
Loading

0 comments on commit 9096367

Please sign in to comment.