Add unread chat indicator
This commit is contained in:
+10
-3
@@ -199,6 +199,8 @@ async function openConversation(id) {
|
||||
state.activeId = id;
|
||||
const data = await api(`/api/admin/conversations/${id}`);
|
||||
state.active = data;
|
||||
const index = state.conversations.findIndex((item) => item.id === id);
|
||||
if (index >= 0) state.conversations[index] = { ...state.conversations[index], ...data.conversation };
|
||||
renderConversations();
|
||||
renderActive();
|
||||
}
|
||||
@@ -246,10 +248,15 @@ function renderSite() {
|
||||
function renderConversations() {
|
||||
const conversations = filteredConversations();
|
||||
$("#conversationList").innerHTML = conversations.length ? conversations.map((item) => `
|
||||
<article class="conversation-item ${item.id === state.activeId ? "active" : ""} ${item.status === "new" ? "fresh" : ""}">
|
||||
<article class="conversation-item ${item.id === state.activeId ? "active" : ""} ${item.hasUnread ? "unread fresh" : ""}">
|
||||
<button class="conversation-open" type="button" data-open="${item.id}">
|
||||
<span class="row"><strong>${escapeHtml(item.visitor.name || item.visitor.email || "Navstevnik")}</strong>${item.imageCount ? `<span class="photo-count">foto ${item.imageCount}</span>` : ""}</span>
|
||||
<span class="preview">${escapeHtml(item.lastBody || "")}</span>
|
||||
<span class="row visitor-row">
|
||||
<span class="visitor-name-wrap">
|
||||
<span class="unread-dot" aria-label="${item.hasUnread ? "Neprecteno" : "Precteno"}"></span>
|
||||
<strong>${escapeHtml(item.visitor.name || item.visitor.email || "Navstevnik")}</strong>
|
||||
</span>
|
||||
${item.imageCount ? `<span class="photo-count">foto ${item.imageCount}</span>` : ""}
|
||||
</span>
|
||||
<span class="visitor-facts">
|
||||
<span title="Zeme">${visitorCountry(item)}</span>
|
||||
<span title="Doba na webu">${formatDuration(item.sessionSeconds)}</span>
|
||||
|
||||
Reference in New Issue
Block a user