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; 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) { socket.on("CHANNEL_DELETE", function (chan) {
for (var i = 0; i < guild_channels_list.length; i++) { for (var i = 0; i < guild_channels_list.length; i++) {
var thatchannel = guild_channels_list[i]; var thatchannel = guild_channels_list[i];

View File

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