mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
If a new message arrives, replace the teaser with the new message content, closes #3623
This commit is contained in:
@@ -49,8 +49,8 @@
|
|||||||
"nodebb-plugin-spam-be-gone": "0.4.2",
|
"nodebb-plugin-spam-be-gone": "0.4.2",
|
||||||
"nodebb-rewards-essentials": "0.0.5",
|
"nodebb-rewards-essentials": "0.0.5",
|
||||||
"nodebb-theme-lavender": "2.0.1",
|
"nodebb-theme-lavender": "2.0.1",
|
||||||
"nodebb-theme-persona": "3.0.14",
|
"nodebb-theme-persona": "3.0.15",
|
||||||
"nodebb-theme-vanilla": "4.0.9",
|
"nodebb-theme-vanilla": "4.0.10",
|
||||||
"nodebb-widget-essentials": "2.0.1",
|
"nodebb-widget-essentials": "2.0.1",
|
||||||
"npm": "^2.1.4",
|
"npm": "^2.1.4",
|
||||||
"passport": "^0.3.0",
|
"passport": "^0.3.0",
|
||||||
|
|||||||
@@ -155,34 +155,32 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
|||||||
data.message.newSet = lastSpeaker !== data.message.fromuid;
|
data.message.newSet = lastSpeaker !== data.message.fromuid;
|
||||||
Chats.parseMessage(data.message, onMessagesParsed);
|
Chats.parseMessage(data.message, onMessagesParsed);
|
||||||
} else {
|
} else {
|
||||||
var contactEl = $('.chats-list li[data-uid="' + data.withUid + '"]'),
|
var contactEl = $('[component="chat/recent"] li[data-uid="' + data.withUid + '"]'),
|
||||||
userKey = data.withUid === data.message.fromuid ? 'fromUser' : 'toUser';
|
userKey = data.withUid === data.message.fromuid ? 'fromUser' : 'toUser';
|
||||||
|
|
||||||
// Spawn a new contact if required
|
// Spawn a new contact if required
|
||||||
if (!contactEl.length) {
|
templates.parse('partials/chat_contact', {
|
||||||
templates.parse('partials/chat_contact', {
|
uid: data.withUid,
|
||||||
uid: data.withUid,
|
username: data.message[userKey].username,
|
||||||
username: data.message[userKey].username,
|
status: data.message[userKey].status,
|
||||||
status: data.message[userKey].status,
|
picture: data.message[userKey].picture,
|
||||||
picture: data.message[userKey].picture,
|
teaser: {
|
||||||
teaser: {
|
content: data.message.cleanedContent,
|
||||||
content: data.message.cleanedContent,
|
timestampISO: new Date(Date.now()).toISOString()
|
||||||
timestampISO: new Date(Date.now()).toISOString()
|
}
|
||||||
|
}, function(html) {
|
||||||
|
translator.translate(html, function(translatedHTML) {
|
||||||
|
if (contactEl.length) {
|
||||||
|
contactEl.replaceWith(translatedHTML);
|
||||||
|
} else {
|
||||||
|
$('[component="chat/recent"]').prepend(translatedHTML);
|
||||||
}
|
}
|
||||||
}, function(html) {
|
|
||||||
translator.translate(html, function(translatedHTML) {
|
|
||||||
$('.chats-list').prepend(translatedHTML);
|
|
||||||
|
|
||||||
// Mark that contact list entry unread
|
// Mark that contact list entry unread
|
||||||
$('.chats-list li[data-uid="' + data.withUid + '"]').addClass('unread').find('.timeago').timeago();
|
$('.chats-list li[data-uid="' + data.withUid + '"]').addClass('unread').find('.timeago').timeago();
|
||||||
});
|
app.alternatingTitle('[[modules:chat.user_has_messaged_you, ' + data.message.fromUser.username + ']]');
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
// Mark that contact list entry unread
|
|
||||||
$('.chats-list li[data-uid="' + data.withUid + '"]').addClass('unread');
|
|
||||||
}
|
|
||||||
|
|
||||||
app.alternatingTitle('[[modules:chat.user_has_messaged_you, ' + data.message.fromUser.username + ']]');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user