Update chat UI(#84)

This commit is contained in:
Phuoc Anh Kha Le 2023-09-25 02:12:06 -05:00 committed by GitHub
parent db37cb4c40
commit b417c08bfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 124 additions and 89 deletions

View file

@ -279,6 +279,21 @@
$("#click_space_" + window.other_user_id).addClass("selected-status-row");
}
function show_right_panel() {
if (isMobile) {
$('.chat-left-panel').hide();
$('#chat-area').css('display', 'flex');
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
}
}
function hide_right_panel() {
if (isMobile) {
$('.chat-left-panel').show();
$('#chat-area').hide();
}
}
function load_room(encrypted_user) {
if (window.lock_click_space) return;
@ -288,6 +303,7 @@
update_last_seen();
refresh_status();
$('#chat-input').focus();
show_right_panel();
}
window.lock_click_space = true;
if (encrypted_user) {
@ -314,6 +330,7 @@
function register_click_space() {
$('.click_space').on('click', function(e) {
if ($(this).attr('id') == 'click_space_' + window.other_user_id) {
show_right_panel();
return;
}
var other_user = $(this).attr('value');
@ -323,10 +340,10 @@
if (window.room_id) {
load_room(null);
}
else {
show_right_panel();
}
});
if (isMobile) {
$('#chat-tab a').click();
}
}
function update_last_seen() {
@ -439,26 +456,6 @@
return true
});
$('#chat-tab').find('a').click(function (e) {
e.preventDefault();
$('#chat-tab').addClass('active');
$('#online-tab').removeClass('active');
$('.chat-left-panel').show();
$('.chat-right-panel').hide();
});
$('#online-tab').find('a').click(function (e) {
e.preventDefault();
$('#online-tab').addClass('active');
$('#chat-tab').removeClass('active');
$('.chat-left-panel').hide();
$('.chat-right-panel').show();
});
$('#refresh-button').on('click', function(e) {
e.preventDefault();
refresh_status();
});
setInterval(refresh_status, 2 * 60 * 1000);
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
@ -466,7 +463,7 @@
const button = document.querySelector('#emoji-button');
const tooltip = document.querySelector('.tooltip');
Popper.createPopper(button, tooltip, {
placement: 'left-end',
placement: isMobile ? 'auto-end' : 'left-end',
});
function toggleEmoji() {
@ -558,5 +555,16 @@
}
register_setting();
color_selected_room();
$('#chat-input').on('input', function() {
if (this.scrollHeight > this.clientHeight) {
this.style.height = (this.scrollHeight) + 'px';
$(this).css('border-radius', '30px');
} else {
$(this).css('height', '80%');
}
});
$('#submit-button').on('click', submit_chat);
});
</script>