feat: remove check for updates in market releases
This commit is contained in:
2
Makefile
2
Makefile
@@ -37,7 +37,7 @@ android-apk-release:
|
||||
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi --target $(TARGET)
|
||||
|
||||
android-aab-release:
|
||||
flutter build appbundle --target $(TARGET)
|
||||
flutter build appbundle --target $(TARGET) --dart-define release=google-play
|
||||
|
||||
windows-release:
|
||||
flutter_distributor package --platform windows --targets exe --skip-clean --build-target $(TARGET)
|
||||
|
||||
@@ -22,20 +22,25 @@ class AppRepositoryImpl
|
||||
name: packageInfo.appName,
|
||||
version: packageInfo.version,
|
||||
buildNumber: packageInfo.buildNumber,
|
||||
release: Release.read(),
|
||||
installerMedia: packageInfo.installerStore,
|
||||
operatingSystem: Platform.operatingSystem,
|
||||
environment: environment,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO add market-specific update checking
|
||||
@override
|
||||
TaskEither<AppFailure, RemoteVersionInfo> getLatestVersion({
|
||||
bool includePreReleases = false,
|
||||
Release release = Release.general,
|
||||
}) {
|
||||
return exceptionHandler(
|
||||
() async {
|
||||
if (!release.allowCustomUpdateChecker) {
|
||||
throw Exception("custom update checkers are not supported");
|
||||
}
|
||||
final response = await dio.get<List>(Constants.githubReleasesApiUrl);
|
||||
|
||||
if (response.statusCode != 200 || response.data == null) {
|
||||
loggy.warning("failed to fetch latest version info");
|
||||
return left(const AppFailure.unexpected());
|
||||
|
||||
@@ -13,6 +13,7 @@ class AppInfo with _$AppInfo {
|
||||
required String name,
|
||||
required String version,
|
||||
required String buildNumber,
|
||||
required Release release,
|
||||
String? installerMedia,
|
||||
required String operatingSystem,
|
||||
required Environment environment,
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
import 'package:dartx/dartx.dart';
|
||||
|
||||
enum Environment {
|
||||
prod,
|
||||
dev;
|
||||
}
|
||||
|
||||
enum Release {
|
||||
general("general"),
|
||||
googlePlay("google-play");
|
||||
|
||||
const Release(this.key);
|
||||
|
||||
final String key;
|
||||
|
||||
bool get allowCustomUpdateChecker => this == general;
|
||||
|
||||
static Release read() =>
|
||||
Release.values.firstOrNullWhere(
|
||||
(e) => e.key == const String.fromEnvironment("release"),
|
||||
) ??
|
||||
Release.general;
|
||||
}
|
||||
|
||||
@@ -88,19 +88,20 @@ class AboutPage extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(t.about.checkForUpdate),
|
||||
trailing: appUpdate.isLoading
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: const Icon(Icons.update),
|
||||
onTap: () {
|
||||
ref.invalidate(appUpdateNotifierProvider);
|
||||
},
|
||||
),
|
||||
if (appInfo.release.allowCustomUpdateChecker)
|
||||
ListTile(
|
||||
title: Text(t.about.checkForUpdate),
|
||||
trailing: appUpdate.isLoading
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: const Icon(Icons.update),
|
||||
onTap: () {
|
||||
ref.invalidate(appUpdateNotifierProvider);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(t.settings.general.openWorkingDir),
|
||||
trailing: const Icon(Icons.arrow_outward_outlined),
|
||||
|
||||
@@ -11,7 +11,15 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger {
|
||||
@override
|
||||
Future<RemoteVersionInfo?> build() async {
|
||||
loggy.debug("checking for update");
|
||||
final currentVersion = ref.watch(appInfoProvider).version;
|
||||
final appInfo = ref.watch(appInfoProvider);
|
||||
// TODO use market-specific update checkers
|
||||
if (!appInfo.release.allowCustomUpdateChecker) {
|
||||
loggy.debug(
|
||||
"custom update checkers are not allowed for [${appInfo.release.name}] release",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
final currentVersion = appInfo.version;
|
||||
return ref
|
||||
.watch(appRepositoryProvider)
|
||||
.getLatestVersion(includePreReleases: true)
|
||||
@@ -27,7 +35,8 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger {
|
||||
return remote;
|
||||
}
|
||||
loggy.info(
|
||||
"already using latest version[$currentVersion], remote: $remote");
|
||||
"already using latest version[$currentVersion], remote: $remote",
|
||||
);
|
||||
return null;
|
||||
},
|
||||
).run();
|
||||
|
||||
Reference in New Issue
Block a user