diff --git a/web/repertory/lib/models/auth.dart b/web/repertory/lib/models/auth.dart index badcd8aa..6ae0dcb6 100644 --- a/web/repertory/lib/models/auth.dart +++ b/web/repertory/lib/models/auth.dart @@ -74,9 +74,8 @@ class Auth with ChangeNotifier { _authenticated = false; _key = SecureKey.random(constants.sodium, 32); _user = ""; + mountList?.clear(notify: false); notifyListeners(); - - mountList?.clear(); } } diff --git a/web/repertory/lib/models/mount_list.dart b/web/repertory/lib/models/mount_list.dart index 219c9308..34f89783 100644 --- a/web/repertory/lib/models/mount_list.dart +++ b/web/repertory/lib/models/mount_list.dart @@ -16,11 +16,7 @@ class MountList with ChangeNotifier { MountList(this._auth) { _auth.mountList = this; - _auth.addListener(() { - if (_auth.authenticated) { - _fetch(); - } - }); + _auth.addListener(_listener); } List _mountList = []; @@ -177,8 +173,12 @@ class MountList with ChangeNotifier { return ret; } - void clear() { + void clear({bool notify = true}) { _mountList = []; + if (!notify) { + return; + } + notifyListeners(); } @@ -198,4 +198,16 @@ class MountList with ChangeNotifier { Future.delayed(Duration(seconds: 1), _fetch); } + + void _listener() { + if (_auth.authenticated) { + _fetch(); + } + } + + @override + void dispose() { + _auth.removeListener(_listener); + super.dispose(); + } }