Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete user from mention list after mention them for duplicate case like zalo,fb? #124

Open
quocviet1996 opened this issue May 10, 2024 · 0 comments

Comments

@quocviet1996
Copy link

quocviet1996 commented May 10, 2024

I wanna ask like fb, when user A is mentioned, then we can't mention duplicate A. So how to implement such a function? Thanks
I'm trying to delete user mention has been chosen on onSearchChanged, but after that an user mention before has been remove from markup too. You can see this in my attach image
image

     onSearchChanged:
                                  (String trigger, String value) {
                                if (trigger == "@") {
                                  if (_debounce?.isActive ?? false)
                                    _debounce!.cancel();
                                  _debounce = Timer(
                                      const Duration(milliseconds: 200),
                                      () {
                                    setState(() {
                                      mentiondata.clear();

                                      final List<Map<String, dynamic>>
                                          mentionTemp = [];
                                      mentionTemp.addAll([
                                        {
                                          "id": "3",
                                          "display": "fayeedP",
                                          "photo":
                                              "https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg"
                                        },
                                        {
                                          "id": "5",
                                          "display": "khaled",
                                          "photo":
                                              "https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg",
                                        },
                                      ]);
                                      String text = _bloc.key.currentState!
                                          .controller!.markupText;
                                      RegExp regex = RegExp(
                                          r"@\[\__([a-zA-Z0-9]+)__\]");

                                      Iterable<Match> matches =
                                          regex.allMatches(text);
                                      List<String> results = [];

                                      for (Match match in matches) {
                                        results.add(match.group(1)!);
                                      }
                                      results.forEach((item) {
                                        mentionTemp.removeWhere((element) =>
                                            element['id'] == item);
                                      });
                                      mentiondata = mentionTemp;
                                    });
                                  });
                                }
                              },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant