fix(resources): refresh geo file info once the core finishes updating

The file info was re-read as soon as the update RPC returned, before the
core had finished writing the file, so the list kept showing the old size
and time. Refresh when the updating key clears instead, which also covers
automatic and core-initiated updates.

Changelog: Refresh the geo file size and time after an update finishes
This commit is contained in:
chen08209
2026-09-12 00:44:21 +08:00
parent 60f371afd8
commit c5bf5bd487
3 changed files with 100 additions and 6 deletions
+3
View File
@@ -37,6 +37,9 @@ class GeoResourceAction extends _$GeoResourceAction {
.stop(geoResource.updatingKey, current);
}
/// Completes once the Core has accepted the update, not once it finishes.
/// Completion arrives as a geo-update event through [handleCoreUpdate];
/// callers that need it watch [isUpdatingProvider] for the key to clear.
Future<void> updateGeoResource(GeoResource geoResource) async {
_manualUpdates.add(geoResource);
final operation = _startUpdating(geoResource);
+12 -6
View File
@@ -189,15 +189,15 @@ class _GeoResourceListItemState extends ConsumerState<_GeoResourceListItem> {
return file.getFileInfo();
}
Future<void> _handleUpdateGeoDataItem() async {
await globalState.safeRun<void>(() async {
Future<void> _handleUpdateGeoDataItem() {
return globalState.safeRun<void>(() async {
await ref
.read(geoResourceActionProvider.notifier)
.updateGeoResource(widget.type);
}, silence: false);
if (!mounted) {
return;
}
}
void _refreshFileInfo() {
setState(() {
_fileInfoFuture = _getGeoFileInfo(fileName);
});
@@ -223,7 +223,13 @@ class _GeoResourceListItemState extends ConsumerState<_GeoResourceListItem> {
@override
Widget build(BuildContext context) {
final isUpdating = ref.watch(isUpdatingProvider(widget.type.updatingKey));
final updatingKey = widget.type.updatingKey;
ref.listen(isUpdatingProvider(updatingKey), (previous, next) {
if (previous == true && !next) {
_refreshFileInfo();
}
});
final isUpdating = ref.watch(isUpdatingProvider(updatingKey));
final url = ref.watch(
patchClashConfigProvider.select((state) => state.geoXUrl[widget.type]),
);