Handle guild name and image updates realtime

This commit is contained in:
Jeremy Zhang 2017-08-27 08:04:50 +00:00
parent 441a0814ae
commit 8038a1b4fc
2 changed files with 12 additions and 4 deletions

View File

@ -1085,6 +1085,16 @@
emoji_store = emo;
});
socket.on("GUILD_UPDATE", function (guil) {
$("#guild_name").text(guil.name);
if (guil.icon) {
$("#guild_icon").attr("src", guil.icon_url);
$("#guild_icon").show();
} else {
$("#guild_icon").hide();
}
});
socket.on("CHANNEL_DELETE", function (chan) {
for (var i = 0; i < guild_channels_list.length; i++) {
var thatchannel = guild_channels_list[i];

View File

@ -43,10 +43,8 @@
<ul id="guild-nav" class="side-nav">
<li>
<div class="userView">
{% if guild['icon'] %}
<img class="circle" src="{{ generate_guild_icon( guild['id'], guild['icon'] ) }}">
{% endif %}
<span class="name">{{ guild['name']|e }}</span>
<img id="guild_icon" class="circle" src="{{ generate_guild_icon( guild['id'], guild['icon'] ) }}" {% if not guild['icon'] %}style="display: none;"{% endif %}>
<span id="guild_name" class="name">{{ guild['name']|e }}</span>
</div>
</li>