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;
|
if (!mounted) return;
|
||||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
||||||
final client = Client("zenith");
|
final client = Client("zenith");
|
||||||
|
provider.setClient(client);
|
||||||
|
setState(() {
|
||||||
|
showRooms = true;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.checkHomeserver(Uri.parse(homeserver));
|
await client.checkHomeserver(Uri.parse(homeserver));
|
||||||
|
@ -58,10 +62,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
await client.login(LoginType.mLoginPassword,
|
await client.login(LoginType.mLoginPassword,
|
||||||
password: password,
|
password: password,
|
||||||
identifier: AuthenticationUserIdentifier(user: username));
|
identifier: AuthenticationUserIdentifier(user: username));
|
||||||
provider.setClient(client);
|
|
||||||
setState(() {
|
|
||||||
showRooms = true;
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error);
|
print(error);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -81,14 +81,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
if (errorMessage.isNotEmpty)
|
if (errorMessage.isNotEmpty)
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
ErrorWidget(errorMessage),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
errorMessage = "";
|
errorMessage = "";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: const Text("Clear"))
|
child: const Text("Clear")),
|
||||||
|
ErrorWidget(errorMessage),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (showRooms)
|
if (showRooms)
|
||||||
|
|
|
@ -81,13 +81,13 @@ class _RoomsPageState extends State<RoomsPage> {
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Center(child: Consumer<ZenithClientProvider>(
|
child: Center(child: Consumer<ZenithClientProvider>(
|
||||||
builder: (context, provider, child) {
|
builder: (context, provider, child) {
|
||||||
provider.client.roomsLoading?.then((value) {
|
provider.client.onRoomState.stream.listen((event) {
|
||||||
setState(() {
|
setState(() {
|
||||||
loadingRooms = false;
|
loadingRooms = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (provider.client.roomsLoading != null && loadingRooms)
|
if (loadingRooms)
|
||||||
return const CircularProgressIndicator();
|
return const CircularProgressIndicator();
|
||||||
else
|
else
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user