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()); } }