Merge pull request #1312 from ImranR98/dev

Bugfix: don't show 'Apps Updated' toast when nothing was updated (#1307), Disable app page buttons while app info is being updated
This commit is contained in:
Imran
2024-01-20 16:29:47 -05:00
committed by GitHub
2 changed files with 23 additions and 13 deletions

View File

@@ -23,13 +23,18 @@ class AppPage extends StatefulWidget {
class _AppPageState extends State<AppPage> { class _AppPageState extends State<AppPage> {
AppInMemory? prevApp; AppInMemory? prevApp;
bool updating = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var appsProvider = context.watch<AppsProvider>(); var appsProvider = context.watch<AppsProvider>();
var settingsProvider = context.watch<SettingsProvider>(); var settingsProvider = context.watch<SettingsProvider>();
getUpdate(String id, {bool resetVersion = false}) { getUpdate(String id, {bool resetVersion = false}) async {
appsProvider.checkUpdate(id).then((e) { try {
setState(() {
updating = true;
});
await appsProvider.checkUpdate(id);
if (resetVersion) { if (resetVersion) {
appsProvider.apps[id]?.app.additionalSettings['versionDetection'] = appsProvider.apps[id]?.app.additionalSettings['versionDetection'] =
true; true;
@@ -39,10 +44,14 @@ class _AppPageState extends State<AppPage> {
} }
appsProvider.saveApps([appsProvider.apps[id]!.app]); appsProvider.saveApps([appsProvider.apps[id]!.app]);
} }
}).catchError((e) { } catch (err) {
showError(e, context); // ignore: use_build_context_synchronously
return null; showError(err, context);
}); } finally {
setState(() {
updating = false;
});
}
} }
bool areDownloadsRunning = appsProvider.areDownloadsRunning(); bool areDownloadsRunning = appsProvider.areDownloadsRunning();
@@ -339,7 +348,7 @@ class _AppPageState extends State<AppPage> {
} }
getResetInstallStatusButton() => TextButton( getResetInstallStatusButton() => TextButton(
onPressed: app?.app == null onPressed: app?.app == null || updating
? null ? null
: () { : () {
app!.app.installedVersion = null; app!.app.installedVersion = null;
@@ -351,7 +360,8 @@ class _AppPageState extends State<AppPage> {
)); ));
getInstallOrUpdateButton() => TextButton( getInstallOrUpdateButton() => TextButton(
onPressed: (app?.app.installedVersion == null || onPressed: !updating &&
(app?.app.installedVersion == null ||
app?.app.installedVersion != app?.app.latestVersion) && app?.app.installedVersion != app?.app.latestVersion) &&
!areDownloadsRunning !areDownloadsRunning
? () async { ? () async {
@@ -361,7 +371,7 @@ class _AppPageState extends State<AppPage> {
app?.app.id != null ? [app!.app.id] : [], app?.app.id != null ? [app!.app.id] : [],
globalNavigatorKey.currentContext, globalNavigatorKey.currentContext,
); );
if (app?.app.installedVersion != null && !trackOnly) { if (res.isNotEmpty && !trackOnly) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
showMessage(tr('appsUpdated'), context); showMessage(tr('appsUpdated'), context);
} }
@@ -398,7 +408,7 @@ class _AppPageState extends State<AppPage> {
!isVersionDetectionStandard && !isVersionDetectionStandard &&
!trackOnly) !trackOnly)
IconButton( IconButton(
onPressed: app?.downloadProgress != null onPressed: app?.downloadProgress != null || updating
? null ? null
: showMarkUpdatedDialog, : showMarkUpdatedDialog,
tooltip: tr('markUpdated'), tooltip: tr('markUpdated'),
@@ -406,7 +416,7 @@ class _AppPageState extends State<AppPage> {
if (source != null && if (source != null &&
source.combinedAppSpecificSettingFormItems.isNotEmpty) source.combinedAppSpecificSettingFormItems.isNotEmpty)
IconButton( IconButton(
onPressed: app?.downloadProgress != null onPressed: app?.downloadProgress != null || updating
? null ? null
: () async { : () async {
var values = var values =
@@ -458,7 +468,7 @@ class _AppPageState extends State<AppPage> {
: getInstallOrUpdateButton()), : getInstallOrUpdateButton()),
const SizedBox(width: 16.0), const SizedBox(width: 16.0),
IconButton( IconButton(
onPressed: app?.downloadProgress != null onPressed: app?.downloadProgress != null || updating
? null ? null
: () { : () {
appsProvider appsProvider

View File

@@ -696,7 +696,7 @@ class AppsPageState extends State<AppsPage> {
showError(e, context); showError(e, context);
return <String>[]; return <String>[];
}).then((value) { }).then((value) {
if (shouldInstallUpdates) { if (value.isNotEmpty && shouldInstallUpdates) {
showMessage(tr('appsUpdated'), context); showMessage(tr('appsUpdated'), context);
} }
}); });