Fix invalid number of available source updates.

This commit is contained in:
2025-02-21 13:21:03 +08:00
parent fba49233c8
commit 3f10473fb6

View File

@@ -605,6 +605,19 @@ class _ComicSourceWidgetState extends State<_ComicSourceWidget> {
super.dispose(); super.dispose();
} }
int get _availableUpdates {
int c = 0;
ComicSource.availableUpdates.forEach((key, version) {
var source = ComicSource.find(key);
if (source != null) {
if (compareSemVer(version, source.version)) {
c++;
}
}
});
return c;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SliverToBoxAdapter( return SliverToBoxAdapter(
@@ -668,7 +681,7 @@ class _ComicSourceWidgetState extends State<_ComicSourceWidget> {
}).toList(), }).toList(),
).paddingHorizontal(16).paddingBottom(16), ).paddingHorizontal(16).paddingBottom(16),
), ),
if (ComicSource.availableUpdates.isNotEmpty) if (_availableUpdates > 0)
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 8, horizontal: 8,
@@ -687,7 +700,7 @@ class _ComicSourceWidgetState extends State<_ComicSourceWidget> {
Icon(Icons.update, color: context.colorScheme.primary, size: 20,), Icon(Icons.update, color: context.colorScheme.primary, size: 20,),
const SizedBox(width: 8), const SizedBox(width: 8),
Text("@c updates".tlParams({ Text("@c updates".tlParams({
'c': ComicSource.availableUpdates.length, 'c': _availableUpdates,
}), style: ts.withColor(context.colorScheme.primary),), }), style: ts.withColor(context.colorScheme.primary),),
], ],
), ),