mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-16 17:09:31 +01:00
Fix logout crash
This commit is contained in:
parent
e736d32322
commit
bed0d821e3
@ -20,6 +20,7 @@ import '../utils/app_route.dart';
|
|||||||
import '../utils/url_launcher.dart';
|
import '../utils/url_launcher.dart';
|
||||||
import '../utils/client_presence_extension.dart';
|
import '../utils/client_presence_extension.dart';
|
||||||
import 'archive.dart';
|
import 'archive.dart';
|
||||||
|
import 'homeserver_picker.dart';
|
||||||
import 'new_group.dart';
|
import 'new_group.dart';
|
||||||
import 'new_private_chat.dart';
|
import 'new_private_chat.dart';
|
||||||
import 'settings.dart';
|
import 'settings.dart';
|
||||||
@ -222,6 +223,17 @@ class _ChatListState extends State<ChatList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return StreamBuilder<LoginState>(
|
||||||
|
stream: Matrix.of(context).client.onLoginStateChanged.stream,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.data == LoginState.loggedOut) {
|
||||||
|
Timer(Duration(seconds: 1), () {
|
||||||
|
Matrix.of(context).clean();
|
||||||
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
|
AppRoute.defaultRoute(context, HomeserverPicker()),
|
||||||
|
(r) => false);
|
||||||
|
});
|
||||||
|
}
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: Matrix.of(context).onShareContentChanged.stream,
|
stream: Matrix.of(context).onShareContentChanged.stream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@ -250,7 +262,8 @@ class _ChatListState extends State<ChatList> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.person_add),
|
leading: Icon(Icons.person_add),
|
||||||
title: Text(L10n.of(context).newPrivateChat),
|
title: Text(L10n.of(context).newPrivateChat),
|
||||||
onTap: () => _drawerTapAction(NewPrivateChatView()),
|
onTap: () =>
|
||||||
|
_drawerTapAction(NewPrivateChatView()),
|
||||||
),
|
),
|
||||||
Divider(height: 1),
|
Divider(height: 1),
|
||||||
ListTile(
|
ListTile(
|
||||||
@ -288,7 +301,8 @@ class _ChatListState extends State<ChatList> {
|
|||||||
? null
|
? null
|
||||||
: IconButton(
|
: IconButton(
|
||||||
icon: Icon(Icons.close),
|
icon: Icon(Icons.close),
|
||||||
onPressed: () => Matrix.of(context).shareContent = null,
|
onPressed: () =>
|
||||||
|
Matrix.of(context).shareContent = null,
|
||||||
),
|
),
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
title: selectMode == SelectMode.share
|
title: selectMode == SelectMode.share
|
||||||
@ -322,7 +336,8 @@ class _ChatListState extends State<ChatList> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: (AdaptivePageLayout.columnMode(context) ||
|
floatingActionButton:
|
||||||
|
(AdaptivePageLayout.columnMode(context) ||
|
||||||
selectMode == SelectMode.share)
|
selectMode == SelectMode.share)
|
||||||
? null
|
? null
|
||||||
: SpeedDial(
|
: SpeedDial(
|
||||||
@ -336,10 +351,12 @@ class _ChatListState extends State<ChatList> {
|
|||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
label: L10n.of(context).createNewGroup,
|
label: L10n.of(context).createNewGroup,
|
||||||
labelStyle:
|
labelStyle: TextStyle(
|
||||||
TextStyle(fontSize: 18.0, color: Colors.black),
|
fontSize: 18.0, color: Colors.black),
|
||||||
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
onTap: () => Navigator.of(context)
|
||||||
AppRoute.defaultRoute(context, NewGroupView()),
|
.pushAndRemoveUntil(
|
||||||
|
AppRoute.defaultRoute(
|
||||||
|
context, NewGroupView()),
|
||||||
(r) => r.isFirst),
|
(r) => r.isFirst),
|
||||||
),
|
),
|
||||||
SpeedDialChild(
|
SpeedDialChild(
|
||||||
@ -347,9 +364,10 @@ class _ChatListState extends State<ChatList> {
|
|||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
label: L10n.of(context).newPrivateChat,
|
label: L10n.of(context).newPrivateChat,
|
||||||
labelStyle:
|
labelStyle: TextStyle(
|
||||||
TextStyle(fontSize: 18.0, color: Colors.black),
|
fontSize: 18.0, color: Colors.black),
|
||||||
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
onTap: () => Navigator.of(context)
|
||||||
|
.pushAndRemoveUntil(
|
||||||
AppRoute.defaultRoute(
|
AppRoute.defaultRoute(
|
||||||
context, NewPrivateChatView()),
|
context, NewPrivateChatView()),
|
||||||
(r) => r.isFirst),
|
(r) => r.isFirst),
|
||||||
@ -363,14 +381,16 @@ class _ChatListState extends State<ChatList> {
|
|||||||
future: waitForFirstSync(context),
|
future: waitForFirstSync(context),
|
||||||
builder: (BuildContext context, snapshot) {
|
builder: (BuildContext context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
List<Room> rooms =
|
List<Room> rooms = List<Room>.from(
|
||||||
List<Room>.from(Matrix.of(context).client.rooms);
|
Matrix.of(context).client.rooms);
|
||||||
rooms.removeWhere((Room room) =>
|
rooms.removeWhere((Room room) =>
|
||||||
searchMode &&
|
searchMode &&
|
||||||
!room.displayname.toLowerCase().contains(
|
!room.displayname.toLowerCase().contains(
|
||||||
searchController.text.toLowerCase() ?? ""));
|
searchController.text.toLowerCase() ??
|
||||||
|
""));
|
||||||
if (rooms.isEmpty &&
|
if (rooms.isEmpty &&
|
||||||
(!searchMode || publicRoomsResponse == null)) {
|
(!searchMode ||
|
||||||
|
publicRoomsResponse == null)) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -384,23 +404,27 @@ class _ChatListState extends State<ChatList> {
|
|||||||
),
|
),
|
||||||
Text(searchMode
|
Text(searchMode
|
||||||
? L10n.of(context).noRoomsFound
|
? L10n.of(context).noRoomsFound
|
||||||
: L10n.of(context).startYourFirstChat),
|
: L10n.of(context)
|
||||||
|
.startYourFirstChat),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final int publicRoomsCount =
|
final int publicRoomsCount =
|
||||||
(publicRoomsResponse?.publicRooms?.length ?? 0);
|
(publicRoomsResponse?.publicRooms?.length ??
|
||||||
final int totalCount = rooms.length + publicRoomsCount;
|
0);
|
||||||
|
final int totalCount =
|
||||||
|
rooms.length + publicRoomsCount;
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
separatorBuilder: (BuildContext context, int i) =>
|
separatorBuilder:
|
||||||
|
(BuildContext context, int i) =>
|
||||||
i == totalCount - publicRoomsCount
|
i == totalCount - publicRoomsCount
|
||||||
? Material(
|
? Material(
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(
|
title: Text(L10n.of(context)
|
||||||
L10n.of(context).publicRooms),
|
.publicRooms),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
@ -414,17 +438,20 @@ class _ChatListState extends State<ChatList> {
|
|||||||
selectMode == SelectMode.share)
|
selectMode == SelectMode.share)
|
||||||
? Container()
|
? Container()
|
||||||
: PreferredSize(
|
: PreferredSize(
|
||||||
preferredSize: Size.fromHeight(89),
|
preferredSize:
|
||||||
|
Size.fromHeight(89),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 81,
|
height: 81,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection:
|
||||||
|
Axis.horizontal,
|
||||||
itemCount: Matrix.of(context)
|
itemCount: Matrix.of(context)
|
||||||
.client
|
.client
|
||||||
.statusList
|
.statusList
|
||||||
.length,
|
.length,
|
||||||
itemBuilder:
|
itemBuilder: (BuildContext
|
||||||
(BuildContext context, int i) =>
|
context,
|
||||||
|
int i) =>
|
||||||
PresenceListItem(
|
PresenceListItem(
|
||||||
Matrix.of(context)
|
Matrix.of(context)
|
||||||
.client
|
.client
|
||||||
@ -437,8 +464,8 @@ class _ChatListState extends State<ChatList> {
|
|||||||
return i < rooms.length
|
return i < rooms.length
|
||||||
? ChatListItem(
|
? ChatListItem(
|
||||||
rooms[i],
|
rooms[i],
|
||||||
activeChat:
|
activeChat: widget.activeChat ==
|
||||||
widget.activeChat == rooms[i].id,
|
rooms[i].id,
|
||||||
)
|
)
|
||||||
: PublicRoomListItem(publicRoomsResponse
|
: PublicRoomListItem(publicRoomsResponse
|
||||||
.publicRooms[i - rooms.length]);
|
.publicRooms[i - rooms.length]);
|
||||||
@ -453,5 +480,6 @@ class _ChatListState extends State<ChatList> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:fluffychat/components/settings_themes.dart';
|
import 'package:fluffychat/components/settings_themes.dart';
|
||||||
import 'package:fluffychat/views/homeserver_picker.dart';
|
|
||||||
import 'package:fluffychat/views/settings_devices.dart';
|
import 'package:fluffychat/views/settings_devices.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -46,9 +45,6 @@ class _SettingsState extends State<Settings> {
|
|||||||
MatrixState matrix = Matrix.of(context);
|
MatrixState matrix = Matrix.of(context);
|
||||||
await SimpleDialogs(context)
|
await SimpleDialogs(context)
|
||||||
.tryRequestWithLoadingDialog(matrix.client.logout());
|
.tryRequestWithLoadingDialog(matrix.client.logout());
|
||||||
matrix.clean();
|
|
||||||
await Navigator.of(context).pushAndRemoveUntil(
|
|
||||||
AppRoute.defaultRoute(context, HomeserverPicker()), (r) => false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setJitsiInstanceAction(BuildContext context) async {
|
void setJitsiInstanceAction(BuildContext context) async {
|
||||||
|
Loading…
Reference in New Issue
Block a user