Improve the way group conversations are shown in sidebar

This commit is contained in:
Pierre HUBERT 2021-04-05 16:29:46 +02:00
parent 2077538db8
commit f13a60ef90
2 changed files with 39 additions and 8 deletions

View File

@ -132,6 +132,10 @@ add left border
} }
*/ */
.main-sidebar .memberships-list .conversation_memberhsip.group-conversation {
padding-left: 20px;
}
.main-sidebar .memberships-list .conversation_memberhsip.has-unread-msg { .main-sidebar .memberships-list .conversation_memberhsip.has-unread-msg {
background-color: #00a65a30; background-color: #00a65a30;
} }

View File

@ -88,12 +88,12 @@ const SidebarMain = {
}); });
this.refreshMemberships(userMemberships); this.refreshMemberships(userMemberships);
let interval = setInterval(() => { /* TODO RESET let interval = setInterval(() => {
if(userMemberships.isConnected) if(userMemberships.isConnected)
this.refreshMemberships(userMemberships); this.refreshMemberships(userMemberships);
else else
clearInterval(interval); clearInterval(interval);
}, 15000); }, 15000);*/
/*// Recent conversations /*// Recent conversations
@ -311,7 +311,9 @@ const SidebarMain = {
refreshMemberships: function(target){ refreshMemberships: function(target){
WebAppInterface.getMemberships( WebAppInterface.getMemberships(
() => notify("Could not refresh your memberships!", "error"), () => notify("Could not refresh your memberships!", "error"),
(m, u, g, c) => this.applyMemberships(target, m, u, g, c) (m, u, g, c) => {
this.applyMemberships(target, m, u, g, c)
}
); );
}, },
@ -341,7 +343,12 @@ const SidebarMain = {
this.applyFriend(friendsTarget, e.friend, users.get(e.friend.ID_friend)); this.applyFriend(friendsTarget, e.friend, users.get(e.friend.ID_friend));
if(e.type == "group") if(e.type == "group")
this.applyGroup(friendsTarget, groups.get(e.id), e.last_activity); {
const groupConversations = memberships
.filter(el => el.type == "conversation" && el.conv.group_id == e.id)
.map(e => e.conv);
this.applyGroup(friendsTarget, groups.get(e.id), groupConversations, e.last_activity);
}
if(e.type == "conversation") if(e.type == "conversation")
this.applyConversation(friendsTarget, e.conv, convs.get(e.conv.id)); this.applyConversation(friendsTarget, e.conv, convs.get(e.conv.id));
@ -471,9 +478,10 @@ const SidebarMain = {
* *
* @param {HTMLElement} target * @param {HTMLElement} target
* @param {Group} group * @param {Group} group
* @param {Conversation[]} conversations Group conversations
* @param {*} lastactive * @param {*} lastactive
*/ */
applyGroup: function(target, group, lastactive) { applyGroup: function(target, group, conversations, lastactive) {
let li = createElem2({ let li = createElem2({
appendTo: target, appendTo: target,
@ -547,9 +555,17 @@ const SidebarMain = {
}); });
} }
else else
{
// Group last activity // Group last activity
subInfoEl.innerHTML = timeDiffToStr(lastactive); subInfoEl.innerHTML = timeDiffToStr(lastactive);
// Group conversations
for(let conv of conversations) {
this.applyConversation(target, conv, conv.name, true)
}
}
}, },
/** /**
@ -559,7 +575,10 @@ const SidebarMain = {
* @param {Conversation} conv * @param {Conversation} conv
* @param {String} name * @param {String} name
*/ */
applyConversation: function(target, conv, name) { applyConversation: function(target, conv, name, showGroupConversations) {
if (conv.group_id && !showGroupConversations)
return;
let li = createElem2({ let li = createElem2({
appendTo: target, appendTo: target,
@ -568,6 +587,9 @@ const SidebarMain = {
}); });
li.setAttribute("data-membership-conv-id", conv.id) li.setAttribute("data-membership-conv-id", conv.id)
if (conv.group_id)
li.classList.add("group-conversation")
// Check for unread messages // Check for unread messages
if(conv.last_activity > conv.members.find(m => m.user_id == userID()).last_access) { if(conv.last_activity > conv.members.find(m => m.user_id == userID()).last_access) {
li.classList.add("has-unread-msg"); li.classList.add("has-unread-msg");
@ -576,7 +598,12 @@ const SidebarMain = {
let a = createElem2({ let a = createElem2({
appendTo: li, appendTo: li,
type: "a", type: "a",
onclick: () => openConversation(conv.id, true) onclick: () => {
if (!conv.group_id)
openConversation(conv.id, true)
else
Page.openPage("groups/" + conv.group_id + "/conversation/" + conv.id);
}
}); });
// Icon // Icon
@ -616,7 +643,7 @@ const SidebarMain = {
let callLi = createElem2({ let callLi = createElem2({
appendTo: target, appendTo: target,
type: "li", type: "li",
class: "call_notice" class: "call_notice group-conversation"
}); });
let a = createElem2({ let a = createElem2({