clear mount list on login failure
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
parent
6137b69bd3
commit
9fd5b7c03f
@ -5,12 +5,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:repertory/constants.dart' as constants;
|
||||
import 'package:repertory/helpers.dart';
|
||||
import 'package:repertory/models/mount_list.dart';
|
||||
import 'package:sodium_libs/sodium_libs.dart';
|
||||
|
||||
class Auth with ChangeNotifier {
|
||||
bool _authenticated = false;
|
||||
SecureKey _key = SecureKey.random(constants.sodium, 32);
|
||||
String _user = "";
|
||||
MountList? mountList;
|
||||
|
||||
bool get authenticated => _authenticated;
|
||||
SecureKey get key => _key;
|
||||
@ -53,6 +55,7 @@ class Auth with ChangeNotifier {
|
||||
void logoff() {
|
||||
_authenticated = false;
|
||||
_user = "";
|
||||
mountList?.clear();
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ class MountList with ChangeNotifier {
|
||||
final Auth _auth;
|
||||
|
||||
MountList(this._auth) {
|
||||
_auth.mountList = this;
|
||||
_auth.addListener(() {
|
||||
if (_auth.authenticated) {
|
||||
_fetch();
|
||||
@ -166,6 +167,11 @@ class MountList with ChangeNotifier {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_mountList = [];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> reset() async {
|
||||
if (constants.navigatorKey.currentContext == null ||
|
||||
ModalRoute.of(constants.navigatorKey.currentContext!)?.settings.name !=
|
||||
@ -178,8 +184,7 @@ class MountList with ChangeNotifier {
|
||||
'Mount removed externally. Reloading...',
|
||||
);
|
||||
|
||||
_mountList = [];
|
||||
notifyListeners();
|
||||
clear();
|
||||
|
||||
return _fetch();
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:repertory/constants.dart' as constants;
|
||||
import 'package:repertory/models/auth.dart';
|
||||
import 'package:repertory/models/mount.dart';
|
||||
import 'package:repertory/widgets/mount_settings.dart';
|
||||
|
Loading…
x
Reference in New Issue
Block a user