Ensure chat stays at bottom if names/tripcodes change

このコミットが含まれているのは:
n9k 2022-06-15 20:39:02 +00:00
コミット 1f56e635b9
1個のファイルの変更29行の追加0行の削除

ファイルの表示

@ -648,6 +648,10 @@ const on_websocket_message = (event) => {
default_name = receipt.default;
max_chat_scrollback = receipt.scrollback;
// if the chat is scrolled all the way to the bottom, make sure this is
// still the case after updating user names and tripcodes
at_bottom = chat_messages.scrollTop === chat_messages.scrollTopMax;
// update users
users = receipt.users;
update_user_names();
@ -655,6 +659,15 @@ const on_websocket_message = (event) => {
update_user_tripcodes();
update_users_list()
// ensure chat scroll (see above)
if (at_bottom) {
chat_messages.scrollTo({
left: 0,
top: chat_messages.scrollTopMax,
behavior: "instant",
});
}
// appearance form default values
const user = users[TOKEN_HASH];
if (user.name !== null) {
@ -739,10 +752,26 @@ const on_websocket_message = (event) => {
for (const token_hash of Object.keys(receipt.users)) {
users[token_hash] = receipt.users[token_hash];
}
// if the chat is scrolled all the way to the bottom, make sure this is
// still the case after updating user names and tripcodes
at_bottom = chat_messages.scrollTop === chat_messages.scrollTopMax;
// update users
update_user_names();
update_user_colors();
update_user_tripcodes();
update_users_list()
// ensure chat scroll (see above)
if (at_bottom) {
chat_messages.scrollTo({
left: 0,
top: chat_messages.scrollTopMax,
behavior: "instant",
});
}
break;
case "rem-users":