mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
build: support for enabling or disabling the update checker in build time
This commit is contained in:
parent
296f96cf17
commit
1cc62c40a0
@ -5,3 +5,8 @@ PASSWORD=
|
||||
# The format:
|
||||
# SPOTIFY_SECRETS=clintId1:clientSecret1,clientId2:clientSecret2
|
||||
SPOTIFY_SECRETS=
|
||||
|
||||
# 0 or 1
|
||||
# 0 = disable
|
||||
# 1 = enable
|
||||
ENABLE_UPDATE_CHECK=
|
@ -35,6 +35,7 @@ class Assets {
|
||||
AssetGenImage('assets/placeholder.png');
|
||||
static const AssetGenImage spotubeLogoForeground =
|
||||
AssetGenImage('assets/spotube-logo-foreground.jpg');
|
||||
static const String spotubeLogoIco = 'assets/spotube-logo.ico';
|
||||
static const AssetGenImage spotubeLogoPng =
|
||||
AssetGenImage('assets/spotube-logo.png');
|
||||
static const String spotubeLogoSvg = 'assets/spotube-logo.svg';
|
||||
@ -53,6 +54,7 @@ class Assets {
|
||||
emptyBox,
|
||||
placeholder,
|
||||
spotubeLogoForeground,
|
||||
spotubeLogoIco,
|
||||
spotubeLogoPng,
|
||||
spotubeLogoSvg,
|
||||
spotubeScreenshot,
|
||||
|
@ -21,4 +21,9 @@ abstract class Env {
|
||||
"clientSecret": secrets.last,
|
||||
};
|
||||
}).toList();
|
||||
|
||||
@EnviedField(varName: 'ENABLE_UPDATE_CHECK', defaultValue: "1")
|
||||
static final _enableUpdateChecker = _Env._enableUpdateChecker;
|
||||
|
||||
static bool get enableUpdateChecker => _enableUpdateChecker == "1";
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:spotube/collections/env.dart';
|
||||
|
||||
import 'package:spotube/components/shared/links/anchor_button.dart';
|
||||
import 'package:spotube/hooks/use_package_info.dart';
|
||||
@ -29,10 +30,9 @@ void useUpdateChecker(WidgetRef ref) {
|
||||
(jsonDecode(value.body)["tag_name"] as String).replaceAll("v", "");
|
||||
final currentVersion = packageInfo.version == "Unknown"
|
||||
? null
|
||||
: Version.parse(
|
||||
packageInfo.version,
|
||||
);
|
||||
final latestVersion = Version.parse(tagName);
|
||||
: Version.parse(packageInfo.version);
|
||||
final latestVersion =
|
||||
tagName == "nightly" ? null : Version.parse(tagName);
|
||||
return [currentVersion, latestVersion];
|
||||
},
|
||||
[packageInfo.version],
|
||||
@ -46,6 +46,7 @@ void useUpdateChecker(WidgetRef ref) {
|
||||
);
|
||||
|
||||
useEffect(() {
|
||||
if (!Env.enableUpdateChecker) return;
|
||||
if (!isCheckUpdateEnabled) return null;
|
||||
checkUpdate().then((value) {
|
||||
final currentVersion = value.first;
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/collections/env.dart';
|
||||
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/components/settings/color_scheme_picker_dialog.dart';
|
||||
@ -401,13 +402,14 @@ class SettingsPage extends HookConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
SwitchListTile(
|
||||
secondary: const Icon(SpotubeIcons.update),
|
||||
title: const Text("Check for Update"),
|
||||
value: preferences.checkUpdate,
|
||||
onChanged: (checked) =>
|
||||
preferences.setCheckUpdate(checked),
|
||||
),
|
||||
if (Env.enableUpdateChecker)
|
||||
SwitchListTile(
|
||||
secondary: const Icon(SpotubeIcons.update),
|
||||
title: const Text("Check for Update"),
|
||||
value: preferences.checkUpdate,
|
||||
onChanged: (checked) =>
|
||||
preferences.setCheckUpdate(checked),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(SpotubeIcons.info),
|
||||
title: const Text("About Spotube"),
|
||||
|
Loading…
Reference in New Issue
Block a user