Compare commits
No commits in common. "076fbb30fb51ecfb5b15d394c760f55dac26e1c1" and "8ea41bb592b86e2f49b2f838e03006bc04472da5" have entirely different histories.
076fbb30fb
...
8ea41bb592
@ -33,7 +33,14 @@
|
||||
</header>
|
||||
<main>
|
||||
{% block sidebar %}
|
||||
{% include "sidebar_channels.html" %}
|
||||
<aside class="sidebar">
|
||||
<h2 class="no-select">Channels</h2>
|
||||
<ul>
|
||||
{% for channel in channels %}
|
||||
<li><a class="no-select" href="/channel/{{channel['uid']}}.html">{{channel['name']}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</aside>
|
||||
{% endblock %}
|
||||
{% block main %}
|
||||
<chat-window class="chat-area"></chat-window>
|
||||
|
||||
@ -1,64 +0,0 @@
|
||||
<style>
|
||||
.channel-list-item-highlight {
|
||||
/* xxx */
|
||||
}
|
||||
</style>
|
||||
<aside class="sidebar" id="channelSidebar">
|
||||
<h2 class="no-select">Channels</h2>
|
||||
<ul>
|
||||
{% for channel in channels %}
|
||||
<li id="channel-list-item-{{channel['uid']}}"><a class="no-select" href="/channel/{{channel['uid']}}.html">{{channel['name']}} <span class="message-count"></span></a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</aside>
|
||||
<script>
|
||||
class ChannelSidebar {
|
||||
constructor(el){
|
||||
this.el = el
|
||||
}
|
||||
get channelNodes() {
|
||||
return this.el.querySelectorAll("li")
|
||||
}
|
||||
channelListItemByUid(channelUid){
|
||||
const id = "channel-list-item-" + channelUid;
|
||||
console.error(id)
|
||||
return document.getElementById(id)
|
||||
}
|
||||
incrementMessageCount(channelUid){
|
||||
let messageCount = this.getMessageCount(channelUid)
|
||||
messageCount++;
|
||||
this.setMessageCount(channelUid, messageCount)
|
||||
}
|
||||
getMessageCount(channelUid){
|
||||
const li = this.channelListItemByUid(channelUid);
|
||||
if(li){
|
||||
let messageCount = li.dataset['messageCount']
|
||||
if(!messageCount){
|
||||
return 0
|
||||
}
|
||||
return new Number(messageCount)
|
||||
}
|
||||
}
|
||||
setMessageCount(channelUid, count){
|
||||
const li = this.channelListItemByUid(channelUid);
|
||||
if(li){
|
||||
li.dataset.messageCount = new String(count)
|
||||
li.dataset['messageCount'] = count
|
||||
li.querySelector(".message-count").textContent = '(' + count + ')'
|
||||
}
|
||||
}
|
||||
notify(message){
|
||||
const li = this.channelListItemByUid(message.channel_uid);
|
||||
if(li){
|
||||
this.incrementMessageCount(message.channel_uid)
|
||||
li.classList.add("channel-list-item-highlight")
|
||||
li.querySelectorAll("a").forEach(el=>{
|
||||
el.style.color = message.color
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
const channelSidebar = new ChannelSidebar(document.getElementById("channelSidebar"))
|
||||
|
||||
</script>
|
||||
@ -132,7 +132,6 @@
|
||||
app.addEventListener("channel-message", (data) => {
|
||||
if (data.channel_uid !== channelUid) {
|
||||
if(!isMentionForSomeoneElse(data.message)){
|
||||
channelSidebar.notify(data);
|
||||
app.playSound("messageOtherChannel");
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ class WebView(BaseView):
|
||||
other_user = await self.app.services.channel_member.get_other_dm_user(subscribed_channel["channel_uid"], self.session.get("uid"))
|
||||
if other_user:
|
||||
item["name"] = other_user["nick"]
|
||||
item["uid"] = subscribed_channel["channel_uid"]
|
||||
item["uid"] = other_user["uid"]
|
||||
else:
|
||||
item["name"] = subscribed_channel["label"]
|
||||
item["uid"] = subscribed_channel["channel_uid"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user