diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 0cba8ce384..f75f615e55 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -363,6 +363,7 @@ }); socket.on('event:new_post', function(data) { + data.posts[0].display_moderator_tools = 'none'; var html = templates.prepare(templates['topic'].blocks['posts']).parse(data), uniqueid = new Date().getTime(); @@ -372,6 +373,11 @@ .append(html) .fadeIn('slow'); + socket.once('api:post.privileges', function(privileges) { + if (privileges.editable) toggle_mod_tools(data.posts[0].pid, true); + }); + socket.emit('api:post.privileges', data.posts[0].pid); + set_up_posts(uniqueid); addCommasToNumbers(); @@ -671,4 +677,18 @@ replyEl.addClass('none'); } } + + function toggle_mod_tools(pid, state) { + var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')), + editEl = postEl.find('.edit'), + deleteEl = postEl.find('.delete'); + + if (state) { + editEl.removeClass('none'); + deleteEl.removeClass('none'); + } else { + editEl.addClass('none'); + deleteEl.addClass('none'); + } + } })(); \ No newline at end of file