|
|
@ -29,22 +29,24 @@ class SearchView extends StatelessWidget {
|
|
|
|
.client
|
|
|
|
.client
|
|
|
|
.queryPublicRooms(
|
|
|
|
.queryPublicRooms(
|
|
|
|
server: server,
|
|
|
|
server: server,
|
|
|
|
genericSearchTerm: controller.genericSearchTerm,
|
|
|
|
filter: PublicRoomQueryFilter(
|
|
|
|
|
|
|
|
genericSearchTerm: controller.genericSearchTerm,
|
|
|
|
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.catchError((error) {
|
|
|
|
.catchError((error) {
|
|
|
|
if (!(controller.genericSearchTerm?.isValidMatrixId ?? false)) {
|
|
|
|
if (!(controller.genericSearchTerm?.isValidMatrixId ?? false)) {
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PublicRoomsResponse.fromJson({
|
|
|
|
return QueryPublicRoomsResponse.fromJson({
|
|
|
|
'chunk': [],
|
|
|
|
'chunk': [],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).then((PublicRoomsResponse res) {
|
|
|
|
}).then((QueryPublicRoomsResponse res) {
|
|
|
|
if (controller.genericSearchTerm != null &&
|
|
|
|
if (controller.genericSearchTerm != null &&
|
|
|
|
!res.chunk.any((room) =>
|
|
|
|
!res.chunk.any((room) =>
|
|
|
|
(room.aliases?.contains(controller.genericSearchTerm) ?? false) ||
|
|
|
|
(room.aliases?.contains(controller.genericSearchTerm) ?? false) ||
|
|
|
|
room.canonicalAlias == controller.genericSearchTerm)) {
|
|
|
|
room.canonicalAlias == controller.genericSearchTerm)) {
|
|
|
|
// we have to tack on the original alias
|
|
|
|
// we have to tack on the original alias
|
|
|
|
res.chunk.add(PublicRoom.fromJson(<String, dynamic>{
|
|
|
|
res.chunk.add(PublicRoomsChunk.fromJson(<String, dynamic>{
|
|
|
|
'aliases': [controller.genericSearchTerm],
|
|
|
|
'aliases': [controller.genericSearchTerm],
|
|
|
|
'name': controller.genericSearchTerm,
|
|
|
|
'name': controller.genericSearchTerm,
|
|
|
|
}));
|
|
|
|
}));
|
|
|
@ -105,10 +107,10 @@ class SearchView extends StatelessWidget {
|
|
|
|
title: Text(L10n.of(context).changeTheServer),
|
|
|
|
title: Text(L10n.of(context).changeTheServer),
|
|
|
|
onTap: controller.setServer,
|
|
|
|
onTap: controller.setServer,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
FutureBuilder<PublicRoomsResponse>(
|
|
|
|
FutureBuilder<QueryPublicRoomsResponse>(
|
|
|
|
future: controller.publicRoomsResponse,
|
|
|
|
future: controller.publicRoomsResponse,
|
|
|
|
builder: (BuildContext context,
|
|
|
|
builder: (BuildContext context,
|
|
|
|
AsyncSnapshot<PublicRoomsResponse> snapshot) {
|
|
|
|
AsyncSnapshot<QueryPublicRoomsResponse> snapshot) {
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
@ -183,10 +185,7 @@ class SearchView extends StatelessWidget {
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Avatar(
|
|
|
|
Avatar(publicRoomsResponse.chunk[i].avatarUrl,
|
|
|
|
Uri.parse(publicRoomsResponse
|
|
|
|
|
|
|
|
.chunk[i].avatarUrl ??
|
|
|
|
|
|
|
|
''),
|
|
|
|
|
|
|
|
publicRoomsResponse.chunk[i].name),
|
|
|
|
publicRoomsResponse.chunk[i].name),
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
publicRoomsResponse.chunk[i].name,
|
|
|
|
publicRoomsResponse.chunk[i].name,
|
|
|
@ -244,11 +243,11 @@ class SearchView extends StatelessWidget {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
leading: Avatar(
|
|
|
|
leading: Avatar(
|
|
|
|
foundProfile.avatarUrl,
|
|
|
|
foundProfile.avatarUrl,
|
|
|
|
foundProfile.displayname ?? foundProfile.userId,
|
|
|
|
foundProfile.displayName ?? foundProfile.userId,
|
|
|
|
//size: 24,
|
|
|
|
//size: 24,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
title: Text(
|
|
|
|
foundProfile.displayname ??
|
|
|
|
foundProfile.displayName ??
|
|
|
|
foundProfile.userId.localpart,
|
|
|
|
foundProfile.userId.localpart,
|
|
|
|
style: TextStyle(),
|
|
|
|
style: TextStyle(),
|
|
|
|
maxLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|