This commit is contained in:
2025-09-06 13:55:20 -05:00
parent a1cd963683
commit 1c759c2f7e
2 changed files with 19 additions and 8 deletions

View File

@@ -74,9 +74,8 @@ class Auth with ChangeNotifier {
_authenticated = false; _authenticated = false;
_key = SecureKey.random(constants.sodium, 32); _key = SecureKey.random(constants.sodium, 32);
_user = ""; _user = "";
mountList?.clear(notify: false);
notifyListeners(); notifyListeners();
mountList?.clear();
} }
} }

View File

@@ -16,11 +16,7 @@ class MountList with ChangeNotifier {
MountList(this._auth) { MountList(this._auth) {
_auth.mountList = this; _auth.mountList = this;
_auth.addListener(() { _auth.addListener(_listener);
if (_auth.authenticated) {
_fetch();
}
});
} }
List<Mount> _mountList = []; List<Mount> _mountList = [];
@@ -177,8 +173,12 @@ class MountList with ChangeNotifier {
return ret; return ret;
} }
void clear() { void clear({bool notify = true}) {
_mountList = []; _mountList = [];
if (!notify) {
return;
}
notifyListeners(); notifyListeners();
} }
@@ -198,4 +198,16 @@ class MountList with ChangeNotifier {
Future.delayed(Duration(seconds: 1), _fetch); Future.delayed(Duration(seconds: 1), _fetch);
} }
void _listener() {
if (_auth.authenticated) {
_fetch();
}
}
@override
void dispose() {
_auth.removeListener(_listener);
super.dispose();
}
} }