1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Merge pull request #67 from Roslot/master

Semi-bugfix for @mentions
This commit is contained in:
marzavec 2019-06-04 15:27:15 -05:00 committed by GitHub
commit 831a4968f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 20 deletions

View File

@ -264,33 +264,16 @@ var COMMANDS = {
if (ignoredUsers.indexOf(args.nick) >= 0) {
return;
}
if (args.text.toLowerCase().includes("@" + myNick.toLowerCase().split("#")[0])) {
notify(args);
pushMessage(args);
// Indicate the message which was just added via style
document.getElementById("messages").lastChild.style.fontWeight = "bold"
} else {
pushMessage(args);
}
pushMessage(args);
},
info: function (args) {
args.nick = '*';
if (args.from != null && (args.type.toLowerCase() == "whisper" || args.type.toLowerCase() == "invite")) {
notify(args);
pushMessage(args);
// Make the message bold to stand out as a @mention
document.getElementById("messages").lastChild.style.fontWeight = "bold"
} else {
pushMessage(args);
}
pushMessage(args);
},
warn: function (args) {
args.nick = '!';
notify(args);
pushMessage(args);
},
@ -331,8 +314,14 @@ function pushMessage(args) {
// Message container
var messageEl = document.createElement('div');
if (typeof (myNick) === 'string' && args.text.includes('@' + myNick.split('#')[0] + ' ')) {
if (
typeof (myNick) === 'string' && (
args.text.match(new RegExp('@' + myNick.split('#')[0], "gi")) ||
((args.type === "whisper" || args.type === "invite") && args.from)
)
) {
messageEl.classList.add('refmessage');
notify(args);
} else {
messageEl.classList.add('message');
}

View File

@ -65,6 +65,9 @@ ul li {
.message, .refmessage {
padding-bottom: 1em;
}
.refmessage {
font-weight: bold;
}
.nick {
float: left;
width: 16em;