Merge pull request #1095 from thelounge/xpaw/fix-nick-autocomplete
Fix nick autocomplete
This commit is contained in:
commit
691f628e48
@ -339,8 +339,9 @@ $(function() {
|
|||||||
var nicks = chan.find(".users").data("nicks");
|
var nicks = chan.find(".users").data("nicks");
|
||||||
if (nicks) {
|
if (nicks) {
|
||||||
var find = nicks.indexOf(data.msg.from);
|
var find = nicks.indexOf(data.msg.from);
|
||||||
if (find !== -1 && typeof move === "function") {
|
if (find !== -1) {
|
||||||
move(nicks, find, 0);
|
nicks.splice(find, 1);
|
||||||
|
nicks.unshift(data.msg.from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -428,9 +429,9 @@ $(function() {
|
|||||||
.attr("placeholder", nicks.length + " " + (nicks.length === 1 ? "user" : "users"));
|
.attr("placeholder", nicks.length + " " + (nicks.length === 1 ? "user" : "users"));
|
||||||
|
|
||||||
users
|
users
|
||||||
|
.data("nicks", nicks)
|
||||||
.find(".names-original")
|
.find(".names-original")
|
||||||
.html(templates.user(data))
|
.html(templates.user(data));
|
||||||
.data("nicks", nicks);
|
|
||||||
|
|
||||||
// Refresh user search
|
// Refresh user search
|
||||||
if (search.val().length) {
|
if (search.val().length) {
|
||||||
@ -1422,7 +1423,13 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function completeNicks(word) {
|
function completeNicks(word) {
|
||||||
const users = chat.find(".active").find(".names-original");
|
const users = chat.find(".active .users");
|
||||||
|
|
||||||
|
// Lobbies and private chats do not have an user list
|
||||||
|
if (!users.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const words = users.data("nicks");
|
const words = users.data("nicks");
|
||||||
|
|
||||||
return $.grep(
|
return $.grep(
|
||||||
@ -1576,17 +1583,6 @@ $(function() {
|
|||||||
$("#nick-value").text(nick);
|
$("#nick-value").text(nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
function move(array, old_index, new_index) {
|
|
||||||
if (new_index >= array.length) {
|
|
||||||
var k = new_index - array.length;
|
|
||||||
while ((k--) + 1) {
|
|
||||||
this.push(undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
array.splice(new_index, 0, array.splice(old_index, 1)[0]);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleNotificationMarkers(newState) {
|
function toggleNotificationMarkers(newState) {
|
||||||
// Toggles the favicon to red when there are unread notifications
|
// Toggles the favicon to red when there are unread notifications
|
||||||
if (favicon.data("toggled") !== newState) {
|
if (favicon.data("toggled") !== newState) {
|
||||||
|
Loading…
Reference in New Issue
Block a user