fixing bug where the favourites star was still shaded in if an anon tried to favourite a post

v1.18.x
Julian Lam 12 years ago
parent 71482163ed
commit 6013017ffd

@ -280,7 +280,8 @@
'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room', '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_deleted', 'event:topic_restored', 'event:topic:locked',
'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned', '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) { socket.on('api:get_users_in_room', function(users) {
var anonymous = users.anonymous, 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) { socket.on('event:post_deleted', function(data) {
if (data.pid) toggle_post_delete_state(data.pid, true); if (data.pid) toggle_post_delete_state(data.pid, true);
}); });
@ -420,7 +428,6 @@
pid = ids[0], pid = ids[0],
uid = ids[1]; uid = ids[1];
if (thread_state.locked !== '1') { if (thread_state.locked !== '1') {
if (this.children[1].className == 'icon-star-empty') { if (this.children[1].className == 'icon-star-empty') {
this.children[1].className = 'icon-star'; this.children[1].className = 'icon-star';

@ -277,6 +277,11 @@ marked.setOptions({
type: 'error', type: 'error',
timeout: 5000 timeout: 5000
}); });
socket.emit('api:posts.favourite', {
status: 'error',
pid: pid
});
return; return;
} }
@ -293,6 +298,10 @@ marked.setOptions({
if (room_id) { if (room_id) {
io.sockets.in(room_id).emit('event:rep_up', {uid: uid !== uid_of_poster ? uid_of_poster : 0, pid: pid}); 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'
});
} }
}); });
}); });

Loading…
Cancel
Save