diff --git a/index.html b/index.html index 0c2e8e6..b5d2f70 100644 --- a/index.html +++ b/index.html @@ -238,7 +238,7 @@ - +

Compose Mail

+

You can send mail to multiple FLO IDs by entering comma separated IDs

@@ -1302,7 +1303,11 @@ case 'time-only': return finalHours; case 'relative': - return relativeTime.from(timestamp) + // check if timestamp is older than a day + if (Date.now() - new Date(timestamp) < 60 * 60 * 24 * 1000) + return `${finalHours}`; + else + return relativeTime.from(timestamp) default: return `${month} ${date}, ${year} at ${finalHours}`; } @@ -2018,28 +2023,12 @@ } if (type !== 'contact') { //render chat card for newly added contact - messenger.getChat(floID).then(chat => { + getLastMessage(floID).then(lastMessage => { + const { lastText, time } = lastMessage const chatCard = getRef('chats_list').querySelector(`.chat[data-flo-id="${floID}"], .group[data-flo-id="${floID}"]`) if (chatCard && !chatCard.querySelector('.last-message')) { - let lastMessage = Object.values(chat).reverse().find(({ message }) => message) || { message: '', time: 0 } - if (type === 'group' && lastMessage.time === 0) - lastMessage.time = messenger.groups[floID].created - const amISender = type === 'chat' && lastMessage.category === 'sent' || type === 'group' && lastMessage.sender === myFloID - let lastText = '' - if (amISender) { - lastText = `You: ${lastMessage.message}` - } else { - if (type === 'group') { - if (lastMessage.sender) - lastText = `${getContactName(lastMessage.sender)}: ${lastMessage.message}` - else - lastText = 'Group created' - } else { - lastText = lastMessage.message - } - } const timeAndOptions = html` - +

${lastText}