Fix login flow and room name updates
1. Logging in with saved credentials should just go straight to rooms page without flickering the login page 2. Rooms should be updated if an event fires for their names changing
This commit is contained in:
parent
27b7f79d74
commit
76411aa827
|
@ -51,6 +51,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
if (!mounted) return;
|
||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
||||
final client = Client("zenith");
|
||||
provider.setClient(client);
|
||||
setState(() {
|
||||
showRooms = true;
|
||||
});
|
||||
|
||||
try {
|
||||
await client.checkHomeserver(Uri.parse(homeserver));
|
||||
|
@ -58,10 +62,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
await client.login(LoginType.mLoginPassword,
|
||||
password: password,
|
||||
identifier: AuthenticationUserIdentifier(user: username));
|
||||
provider.setClient(client);
|
||||
setState(() {
|
||||
showRooms = true;
|
||||
});
|
||||
} catch (error) {
|
||||
print(error);
|
||||
setState(() {
|
||||
|
@ -81,14 +81,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
if (errorMessage.isNotEmpty)
|
||||
return Column(
|
||||
children: [
|
||||
ErrorWidget(errorMessage),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
errorMessage = "";
|
||||
});
|
||||
},
|
||||
child: const Text("Clear"))
|
||||
child: const Text("Clear")),
|
||||
ErrorWidget(errorMessage),
|
||||
],
|
||||
);
|
||||
if (showRooms)
|
||||
|
|
|
@ -81,13 +81,13 @@ class _RoomsPageState extends State<RoomsPage> {
|
|||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(child: Consumer<ZenithClientProvider>(
|
||||
builder: (context, provider, child) {
|
||||
provider.client.roomsLoading?.then((value) {
|
||||
provider.client.onRoomState.stream.listen((event) {
|
||||
setState(() {
|
||||
loadingRooms = false;
|
||||
});
|
||||
});
|
||||
|
||||
if (provider.client.roomsLoading != null && loadingRooms)
|
||||
if (loadingRooms)
|
||||
return const CircularProgressIndicator();
|
||||
else
|
||||
return ListView.builder(
|
||||
|
|
Loading…
Reference in New Issue
Block a user