Compare commits

..

3 Commits

Author SHA1 Message Date
Jarek Radosz
38fdd842f5
UX: Fix chat separator alignment (#20669)
Also: work around 1px svg shift in scroll-to-bottom button
2023-03-18 18:03:54 +01:00
Joffrey JAFFEUX
aeab38aff1
UX: disable arrow up to edit if last message is not editable (#20729) 2023-03-17 23:08:10 +01:00
Joffrey JAFFEUX
aa8eff5e16
FIX: ensures updateLastRead is called when receiving a message (#20728)
This behavior is hard to test as it's mostly fixing a race condition: User A sends a message at the same time than User B, which as a result doesn't cause a scroll for the second message and we don't update last read unless we do a small up and down scroll.

`updateLastRead` is debounced so it has no direct consequences to call it slightly more often than what should ideally be needed.
2023-03-17 22:46:59 +01:00
5 changed files with 33 additions and 21 deletions

View File

@ -8,16 +8,15 @@
}
html.discourse-no-touch {
.btn-default:not(.btn-flat, .btn-danger, .btn-primary),
.btn-icon:not(.btn-flat, .btn-danger, .btn-primary) {
.btn-default:not(.btn-flat),
.btn-icon:not(.btn-flat) {
&.btn-default {
.d-icon {
color: var(--primary-medium);
}
}
&:hover,
&.btn-hover,
&:focus {
&.btn-hover {
.d-icon {
color: var(--secondary);
}
@ -28,7 +27,7 @@ html.discourse-no-touch {
}
.btn-icon.ok,
.btn-icon.cancel,
.btn-danger:not(.btn-flat) {
.btn-danger {
.d-icon {
color: var(--secondary);
}
@ -43,10 +42,6 @@ html.discourse-no-touch {
}
}
}
.select-kit.single-select .select-kit-header:focus {
border-color: var(--primary-medium);
}
}
html {

View File

@ -613,6 +613,7 @@ export default class ChatLivePane extends Component {
const message = ChatMessage.create(this.args.channel, data.chat_message);
this.args.channel.addMessages([message]);
this.scrollToLatestMessage();
this.updateLastReadMessage();
} else {
// If we are almost at the bottom, we append the message and notice the user
const message = ChatMessage.create(this.args.channel, data.chat_message);
@ -895,16 +896,19 @@ export default class ChatLivePane extends Component {
@action
editLastMessageRequested() {
const lastUserMessage = this.args.channel.messages.findLast(
(message) =>
message.user.id === this.currentUser.id &&
!message.staged &&
!message.error
(message) => message.user.id === this.currentUser.id
);
if (lastUserMessage) {
this.editingMessage = lastUserMessage;
this._focusComposer();
if (!lastUserMessage) {
return;
}
if (lastUserMessage.staged || lastUserMessage.error) {
return;
}
this.editingMessage = lastUserMessage;
this._focusComposer();
}
@action

View File

@ -384,6 +384,7 @@ $float-height: 530px;
.d-icon {
color: var(--secondary);
margin-left: 1px; // "fixes" the 1px svg shift
}
}

View File

@ -56,7 +56,9 @@
}
.chat-message-separator__text-container {
padding-top: 7px;
align-items: center;
display: flex;
height: 40px;
position: sticky;
top: -1px;
@ -98,11 +100,7 @@
.chat-message-separator__line {
border-top: 1px solid var(--secondary-high);
left: 0;
margin: 0 0 -1px;
position: relative;
right: 0;
top: -1px;
}
}
}

View File

@ -70,5 +70,19 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do
expect(page.find(".chat-composer-message-details")).to have_content(message_1.message)
end
context "when last message is not editable" do
after { page.driver.browser.network_conditions = { offline: false } }
it "does not edit a message" do
chat.visit_channel(channel_1)
page.driver.browser.network_conditions = { offline: true }
channel_page.send_message("Hello world")
find(".chat-composer-input").send_keys(:arrow_up)
expect(page).to have_no_css(".chat-composer-message-details")
end
end
end
end