Node.js based forum software built for the modern web
fixing bug where the favourites star was still shaded in if an anon tried to favourite a post
Julian Lam6013017ffd60
diff --git a/public/templates/topic.tpl b/public/templates/topic.tplindex ed08976290..365004038c 100644--- a/public/templates/topic.tpl+++ b/public/templates/topic.tpl@@ -280,7 +280,8 @@'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room','event:topic_deleted', 'event:topic_restored', 'event:topic:locked','event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned',- 'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored'+ 'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored',+ 'api:posts.favourite']);socket.on('api:get_users_in_room', function(users) {var anonymous = users.anonymous,@@ -370,6 +371,13 @@});});+ socket.on('api:posts.favourite', function(data) {+ if (data.status !== 'ok' && data.pid) {+ var favEl = document.querySelector('.post_rep_' + data.pid).nextSibling;+ if (favEl) favEl.className = 'icon-star-empty';+ }+ });+socket.on('event:post_deleted', function(data) {if (data.pid) toggle_post_delete_state(data.pid, true);});@@ -420,7 +428,6 @@pid = ids[0],uid = ids[1];-if (thread_state.locked !== '1') {if (this.children[1].className == 'icon-star-empty') {this.children[1].className = 'icon-star';diff --git a/src/posts.js b/src/posts.jsindex e14f67e889..42a98c83e8 100644--- a/src/posts.js+++ b/src/posts.js@@ -277,6 +277,11 @@ marked.setOptions({type: 'error',timeout: 5000});++ socket.emit('api:posts.favourite', {+ status: 'error',+ pid: pid+ });return;}@@ -293,6 +298,10 @@ marked.setOptions({if (room_id) {io.sockets.in(room_id).emit('event:rep_up', {uid: uid !== uid_of_poster ? uid_of_poster : 0, pid: pid});}++ socket.emit('api:posts.favourite', {+ status: 'ok'+ });}});});