Skip to content

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

@quocviet1996

Description

@quocviet1996

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;
                                    });
                                  });
                                }
                              },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions