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

Rework scroll into view of conversation after post #4531

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

PVince81
Copy link
Member

@PVince81 PVince81 commented Nov 4, 2020

Fixes an issue where a chat in the files sidebar would trigger a warning
because the conversation list element don't exist there. See #4291 (comment)

When posting a message, an event is now triggered so other components
could react on it.

The conversation list will now take the responsibility of scrolling the
current conversation into view after posting, instead of the
NewMessageForm.

The behavior is also adjusted to always scroll regardless where the
conversation is located in the list.

@ma12-co not sure why this was limited to only when it moves to the top.
I tested also by clicking on a conversation at the bottom of list, then scrolling up, then posting: it will now scroll down to highlight the conversation even when at the bottom.

Note: I don't understand when a conversation moves to the top and when not, it seemed to be random in my tests... could be another bug.

@PVince81 PVince81 added this to the 💚 Next Major (21) milestone Nov 4, 2020
@PVince81 PVince81 self-assigned this Nov 4, 2020
@PVince81 PVince81 force-pushed the bugfix/noid/fix-scrollintoview-conversation branch from f8ba7e8 to f8fdf33 Compare November 5, 2020 08:22
@PVince81
Copy link
Member Author

PVince81 commented Nov 5, 2020

@danxuliu thanks for the addition, indeed I forgot to off. Squashed.

Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works as described. But I do not know why before the scrolling was done only if it was not the first item in the list*, so I can not approve :-) In any case, code looks good 👍

*Note that as conversationIsFirstInList was updated only on mount and on token change if the conversation moved to the top once the list continued scrolling to the top whenever the current user posted a new message (until the conversation was changed). That was probably unintended, though.

Note: I don't understand when a conversation moves to the top and when not, it seemed to be random in my tests... could be another bug.

For me it always moves to the top when the current user postes a message; I have not dug into the code, though.

// Check whether the current conversation is the first in the conversations
// list and stores the value in the component's data.
isCurrentConversationIsFirstInList() {
this.conversationIsFirstInList = this.$store.getters.conversationsList.map(conversation => conversation.token).indexOf(this.token) === 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't work when you had a favorite and posted in a normal conversation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested in this PR and having a favorite or normal conversation makes no difference.
It just makes sure that whatever room you posted in becomes visible in the left panel.

And when posting in a room that is invisible below the scroll panel, the room gets moved to the top, below favorites, highlighted, and it scrolls to that.

@ma12-co do you know why there was a check for "first room" ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remember honestly :/

Fixes an issue where a chat in the files sidebar would trigger a warning
because the conversation list element don't exist there.

When posting a message, an event is now triggered so other components
could react on it.

The conversation list will now take the responsibility of scrolling the
current conversation into view after posting, instead of the
NewMessageForm.

The behavior is also adjusted to always scroll regardless where the
conversation is located in the list.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Co-Authored-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@PVince81 PVince81 force-pushed the bugfix/noid/fix-scrollintoview-conversation branch from 71d7678 to e3e430e Compare November 6, 2020 09:04
@PVince81
Copy link
Member Author

PVince81 commented Nov 6, 2020

adjusted scrollIntoView to "top" instead of "center", rebased, squashed

Copy link
Member

@marcoambrosini marcoambrosini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested and works

// Check whether the current conversation is the first in the conversations
// list and stores the value in the component's data.
isCurrentConversationIsFirstInList() {
this.conversationIsFirstInList = this.$store.getters.conversationsList.map(conversation => conversation.token).indexOf(this.token) === 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remember honestly :/

@PVince81 PVince81 merged commit 7ce54c8 into master Nov 11, 2020
@PVince81 PVince81 deleted the bugfix/noid/fix-scrollintoview-conversation branch November 11, 2020 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants