diff --git a/layouts/header/script.js b/layouts/header/script.js index d83f8a45..c5cdce34 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -791,9 +791,10 @@ let userDataFunction = async user => { if(inboxData) { let conversations = Array.isArray(inboxData.conversations) ? inboxData.conversations : Object.values(inboxData.conversations); let realConvo = conversations.find(c => c.id_str === lastConvo.id_str); - if(+lastConvo.max_entry_id >= +realConvo.last_read_event_id) { - API.inbox.markRead(lastConvo.max_entry_id); - realConvo.last_read_event_id = lastConvo.max_entry_id; + let lastEventId = lastConvo.conversations[lastConvo.conversation_id].sort_event_id; //reactions dont count towards max_entry_id, but they do towards sort_event_id so that conversations appear above others when theres a new reaction + if(+lastEventId >= +realConvo.last_read_event_id) { + API.inbox.markRead(lastEventId); + realConvo.last_read_event_id = lastEventId; } } window.history.pushState(null, document.title, window.location.href) @@ -1048,11 +1049,35 @@ let userDataFunction = async user => { messageElement.classList.add('inbox-message-unread'); isUnread = true; } + let messageEntry = {} + if(messageUsers.length === 1) { //regular user + if (messageUsers[0].default_profile_image && vars.useOldDefaultProfileImage) { + messageEntry.icon = chrome.runtime.getURL(`images/default_profile_images/default_profile_${Number(messageUsers[0].id_str) % 7}_normal.png`); + } else { + messageEntry.icon = messageUsers[0].profile_image_url_https; + } + + messageEntry.name = escapeHTML(messageUsers[0].name); + messageEntry.screen_name = '@' + messageUsers[0].screen_name; + } else if (messageUsers.length > 1) { //groups + messageEntry.icon = c.avatar_image_https || chrome.runtime.getURL('/images/group.jpg'); + messageEntry.name = c.name ? escapeHTML(c.name) : messageUsers.map(i => escapeHTML(i.name)).join(', ').slice(0, 128); + messageEntry.screen_name = ''; + } else if (messageUsers.length === 0) { //weird twitter bug, if you dm yourself (why?) it counts as no messageUsers + if (user.default_profile_image && vars.useOldDefaultProfileImage) { + messageEntry.icon = chrome.runtime.getURL(`images/default_profile_images/default_profile_${Number(user.id_str) % 7}_normal.png`); + } else { + messageEntry.icon = user.profile_image_url_https; + } + + messageEntry.name = user.name; + messageEntry.screen_name = '@' + user.screen_name; + } messageElement.innerHTML = /*html*/` - +