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
6 changed files with 41 additions and 24 deletions

View File

@ -250,13 +250,12 @@ gem "sanitize"
if ENV["IMPORT"] == "1"
gem "mysql2"
gem "redcarpet"
gem "php_serialize"
gem "miro"
# NOTE: in import mode the version of sqlite can matter a lot, so we stick it to a specific one
gem "sqlite3", "~> 1.3", ">= 1.3.13"
gem "ruby-bbcode-to-md", git: "https://github.com/nlalonde/ruby-bbcode-to-md"
gem "reverse_markdown"
gem "tiny_tds"
gem "csv"
gem "parallel", require: false

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

View File

@ -15,7 +15,7 @@ require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
class ImportScripts::DiscuzX < ImportScripts::Base
DISCUZX_DB = "db_name"
DISCUZX_DB = "ultrax"
DB_TABLE_PREFIX = "pre_"
BATCH_SIZE = 1000
ORIGINAL_SITE_PREFIX = "oldsite.example.com/forums" # without http(s)://
@ -26,8 +26,6 @@ class ImportScripts::DiscuzX < ImportScripts::Base
AVATAR_DIR = "/uc_server/data/avatar"
ATTACHMENT_DIR = "/data/attachment/forum"
AUTHORIZED_EXTENSIONS = %w[jpg jpeg png gif zip rar pdf]
IMPORT_UPLOADS = false
IMPORT_PASSWORDS = false
def initialize
super
@ -37,7 +35,6 @@ class ImportScripts::DiscuzX < ImportScripts::Base
host: "localhost",
username: "root",
#password: "password",
port: "3306",
database: DISCUZX_DB,
)
@first_post_id_by_topic_id = {}
@ -61,7 +58,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
import_categories
import_posts
import_private_messages
import_attachments if IMPORT_UPLOADS
import_attachments
end
# add the prefix to the table name
@ -118,8 +115,8 @@ class ImportScripts::DiscuzX < ImportScripts::Base
@duplicated_email = {}
results =
mysql_query(
"select a.uid uid, b.uid import_id from #{table_name "common_member"} a
join (select uid, email from #{table_name "common_member"} group by email having count(email) > 1 order by uid asc) b USING(email)
"select a.uid uid, b.uid import_id from pre_common_member a
join (select uid, email from pre_common_member group by email having count(email) > 1 order by uid asc) b USING(email)
where a.uid != b.uid",
)
@ -179,6 +176,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
email: user["email"],
username: user["username"],
name: first_exists(user["realname"], user["customstatus"], user["username"]),
import_pass: user["password_hash"],
active: true,
salt: user["salt"],
# TODO: title: user['customstatus'], # move custom title to name since discourse can't let user custom title https://meta.discourse.org/t/let-users-custom-their-title/37626
@ -233,8 +231,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
),
post_create_action:
lambda do |newmember|
if user["avatar_exists"] == (1) && newmember.uploaded_avatar_id.blank? &&
IMPORT_UPLOADS
if user["avatar_exists"] == (1) && newmember.uploaded_avatar_id.blank?
path, filename = discuzx_avatar_fullpath(user["id"])
if path
begin
@ -309,6 +306,10 @@ class ImportScripts::DiscuzX < ImportScripts::Base
end
end
# we don't send email to the unconfirmed user
if newmember.email_digests
newmember.update(email_digests: user["email_confirmed"] == 1)
end
if !newmember.name.blank? && newmember.name == (newmember.username)
newmember.update(name: "")
end
@ -470,7 +471,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
WHERE tid = #{m["topic_id"]}
ORDER BY displayorder",
)
if results.count == 0
if results.empty?
puts "WARNING: can't find poll options for topic #{m["topic_id"]}, skip poll"
else
mapped[