From b3ee45ee87a9f6e3819b8cce312a4bc6d25028d1 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 14 Apr 2022 16:33:36 +0200 Subject: [PATCH] Hotfix for #22 --- lib/components/list.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 ?? [];