diff --git a/lib/components/list.dart b/lib/components/list.dart index 541950d..dfb585c 100644 --- a/lib/components/list.dart +++ b/lib/components/list.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:wsl2distromanager/components/api.dart'; import 'package:fluent_ui/fluent_ui.dart'; import 'package:wsl2distromanager/dialogs/dialogs.dart'; @@ -28,9 +30,17 @@ class _DistroListState extends State { @override void initState() { initPrefs(); + reloadEvery5Seconds(); super.initState(); } + void reloadEvery5Seconds() async { + for (;;) { + await Future.delayed(const Duration(seconds: 5)); + setState(() {}); + } + } + @override Widget build(BuildContext context) { return distroList(widget.api, widget.statusMsg, hover); @@ -43,6 +53,7 @@ FutureBuilder distroList(WSLApi api, return FutureBuilder( future: api.list(), builder: (context, snapshot) { + // Update every 20 seconds if (snapshot.hasData) { List newList = []; List list = snapshot.data?.all ?? [];