From 3d980df674a462e39e31272383e7fa03eee08cff Mon Sep 17 00:00:00 2001 From: Sorunome Date: Wed, 21 Jul 2021 20:46:17 +0200 Subject: [PATCH] feat: Also suggest username completions based on their slugs --- lib/widgets/input_bar.dart | 5 ++++- pubspec.lock | 2 +- pubspec.yaml | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/widgets/input_bar.dart b/lib/widgets/input_bar.dart index 1bb1648c..82fa5d86 100644 --- a/lib/widgets/input_bar.dart +++ b/lib/widgets/input_bar.dart @@ -6,6 +6,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter/services.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:slugify/slugify.dart'; import 'avatar.dart'; import 'matrix.dart'; @@ -110,7 +111,9 @@ class InputBar extends StatelessWidget { final userSearch = userMatch[1].toLowerCase(); for (final user in room.getParticipants()) { if ((user.displayName != null && - user.displayName.toLowerCase().contains(userSearch)) || + (user.displayName.toLowerCase().contains(userSearch) || + slugify(user.displayName.toLowerCase()) + .contains(userSearch))) || user.id.split(':')[0].toLowerCase().contains(userSearch)) { ret.add({ 'type': 'user', diff --git a/pubspec.lock b/pubspec.lock index 8c2a1a83..4fd44ca2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1111,7 +1111,7 @@ packages: source: sdk version: "0.0.99" slugify: - dependency: transitive + dependency: "direct main" description: name: slugify url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index a8544cdd..91acb270 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,7 @@ dependencies: scroll_to_index: ^2.0.0 sentry: ^5.1.0 share: ^2.0.4 + slugify: ^2.0.0 swipe_to_action: ^0.2.0 uni_links: ^0.5.1 unifiedpush: ^1.0.6