Fix chat search

This commit is contained in:
cuom1999 2021-11-20 22:57:47 -06:00
parent 64bdffb590
commit 2d1d12dab5
2 changed files with 33 additions and 15 deletions

View file

@ -295,7 +295,7 @@ let message_template = `
}
}
function register_click_space() {
function load_room(encrypted_user) {
function callback() {
history.replaceState(null, '', "{{url('chat', '')}}" + window.room_id);
load_page(window.currentPage, true, refresh_status);
@ -303,12 +303,8 @@ let message_template = `
refresh_status();
$('#chat-input').focus();
}
$('.click_space').on('click', function(e) {
if ($(this).attr('id') == 'click_space_' + window.other_user_id) {
return;
}
var other_user = $(this).attr('value');
$.get("{{url('get_or_create_room')}}" + `?other=${other_user}`)
if (encrypted_user) {
$.get("{{url('get_or_create_room')}}" + `?other=${encrypted_user}`)
.done(function(data) {
window.currentPage = 1;
window.room_id = data.room;
@ -318,13 +314,26 @@ let message_template = `
.fail(function() {
console.log('Fail to get_or_create_room');
})
}
else {
window.currentPage = 1;
window.room_id = '';
window.other_user_id = '';
callback();
}
}
function register_click_space() {
$('.click_space').on('click', function(e) {
if ($(this).attr('id') == 'click_space_' + window.other_user_id) {
return;
}
var other_user = $(this).attr('value');
load_room(other_user);
});
$('#lobby_row').on('click', function(e) {
if (window.room_id) {
window.currentPage = 1;
window.room_id = '';
window.other_user_id = '';
callback();
load_room(null);
}
});
}
@ -477,6 +486,7 @@ let message_template = `
name: 'other',
onchange: 'form.submit()'
}));
var in_user_redirect = false;
$('#search-handle').select2({
placeholder: '{{ _('Search by handle...') }}',
@ -557,7 +567,8 @@ let message_template = `
<div id="chat-online-content">
<div id="search-container">
<center>
<form id="search-form" name="form" action="{{ url('get_or_create_room') }}" method="get">
<form id="search-form" name="form" action="{{ url('get_or_create_room') }}" method="post">
{% csrf_token %}
<input id="search-handle" type="text" name="search"
placeholder="{{ _('Search by handle...') }}">
</form>