kopia lustrzana https://gitlab.com/mysocialportal/relatica
Make autocomplete work with all known users not just contacts
rodzic
db5fadff9f
commit
45380df0d0
|
@ -17,13 +17,7 @@ class MentionAutocompleteOptions extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final users = getIt<ConnectionsManager>().getMyContacts().where((it) {
|
||||
final normalizedHandle = it.handle.toLowerCase();
|
||||
final normalizedName = it.name.toLowerCase();
|
||||
final normalizedQuery = query.toLowerCase();
|
||||
return normalizedHandle.contains(normalizedQuery) ||
|
||||
normalizedName.contains(normalizedQuery);
|
||||
});
|
||||
final users = getIt<ConnectionsManager>().getKnownUsersByName(query);
|
||||
|
||||
if (users.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
|
@ -46,7 +40,7 @@ class MentionAutocompleteOptions extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
LimitedBox(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.3,
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.2,
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
|
|
|
@ -38,6 +38,16 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
return updateConnection(connection);
|
||||
}
|
||||
|
||||
List<Connection> getKnownUsersByName(String name) {
|
||||
return _connectionsByName.values.where((it) {
|
||||
final normalizedHandle = it.handle.toLowerCase();
|
||||
final normalizedName = it.name.toLowerCase();
|
||||
final normalizedQuery = name.toLowerCase();
|
||||
return normalizedHandle.contains(normalizedQuery) ||
|
||||
normalizedName.contains(normalizedQuery);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
bool updateConnection(Connection connection) {
|
||||
_connectionsById[connection.id] = connection;
|
||||
_connectionsByName[connection.name] = connection;
|
||||
|
|
Ładowanie…
Reference in New Issue