Navigation Menu

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

Thread message is not deleted when using hard: true parameter #871

Closed
1 task done
damian-molinski opened this issue Jan 21, 2022 · 1 comment · Fixed by #876
Closed
1 task done

Thread message is not deleted when using hard: true parameter #871

damian-molinski opened this issue Jan 21, 2022 · 1 comment · Fixed by #876
Labels
bug Something isn't working

Comments

@damian-molinski
Copy link

Which packages are you using?

stream_chat_flutter_core

On what platforms did you experience the issue?

iOS, Android

What version are you using?

stream_chat_flutter_core: ^3.3.1

What happened?

When one of users deletes thread message it does not disappear for other users. It only happens when parameter hard: is set to true.

Steps to reproduce

1. Open same thread on least 2 devices
2. One of users creates message
3. Same user needs to delete message
4. It will not disappear for other user

Supporting info to reproduce

Here is code that you can reproduce this bug with.

This is modified example from core repo with following logic when building message.

  • Shows message text and type,
  • When taping message it opens thread for it.
  • When long pressing message you can hard delete message.
                      final item = messages[index];
                      final client = StreamChatCore.of(context).client;
                      final isCurrentUserMessage = item.user!.id == client.uid;
                      final alignment = isCurrentUserMessage
                          ? Alignment.centerRight
                          : Alignment.centerLeft;

                      final canOpenThread = widget.parentMessage == null;

                      final text = '${item.text!} -> type ${item.type}';

                      return GestureDetector(
                        onTap: canOpenThread
                            ? () {
                                Navigator.of(context).push(
                                  MaterialPageRoute(
                                    builder: (context) {
                                      return StreamChannel(
                                        channel: channel,
                                        child: MessageScreen(
                                          parentMessage: item,
                                        ),
                                      );
                                    },
                                  ),
                                );
                              }
                            : null,
                        onLongPress: isCurrentUserMessage
                            ? () async {
                                final dynamic result = await showDialog<bool>(
                                  context: context,
                                  builder: (_) =>
                                      const DeleteConfirmationDialog(),
                                );

                                if (result == true) {
                                  await channel.deleteMessage(item, hard: true);
                                }
                              }
                            : null,
                        child: Align(
                          alignment: alignment,
                          child: MessageWidget(text: text),
                        ),
                      );

Here is short video showing bug.

hard_delete_thread_message.mov

I was able to narrow down to implementation of ChannelClientState.removeMessage. Basically type of message is different and that's why its not removed.

threads[parentId]!..remove(message)
remove_message_1
remove_message_2

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@damian-molinski damian-molinski added the bug Something isn't working label Jan 21, 2022
@deven98
Copy link
Contributor

deven98 commented Jan 24, 2022

Hi @damianmolinskifdt,

Thanks for such a detailed issue report.
I'm taking a look at this now, I will let you know when I have more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants