From 30113f20fbf7d0c6fccacf56d23d124361d75693 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Fri, 22 Nov 2024 00:20:29 +0100 Subject: [PATCH] Move timer to correct place --- lib/src/web_app/session_manager_plugin.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/web_app/session_manager_plugin.dart b/lib/src/web_app/session_manager_plugin.dart index 43e313f..f2da484 100644 --- a/lib/src/web_app/session_manager_plugin.dart +++ b/lib/src/web_app/session_manager_plugin.dart @@ -15,8 +15,8 @@ class SessionManagerPlugin extends NyxxPlugin { } @override - FutureOr afterConnect(NyxxGateway client) { - restoreSessions(() async { + FutureOr afterConnect(NyxxGateway client) async { + await restoreSessions(() async { final file = File(_sessionsFile); if (await file.exists()) { logger.info("Loading session file."); @@ -26,12 +26,12 @@ class SessionManagerPlugin extends NyxxPlugin { logger.info("Session file missing. Returning default"); return '{}'; }); + + Timer.periodic(Duration(minutes: 15), (timer) => _saveSessions()); } @override FutureOr afterClose() async { _saveSessions(); - - Timer.periodic(Duration(minutes: 15), (timer) => _saveSessions()); } }