pass the loaded pids to action:posts.loaded

v1.18.x
barisusakli 10 years ago
parent 835ad3ea53
commit 288d507eb6

@ -127,32 +127,31 @@ define('forum/topic/posts', [
html.hide().fadeIn('slow'); html.hide().fadeIn('slow');
$(window).trigger('action:posts.loaded'); var pids = [];
onNewPostsLoaded(html, data.posts); for(var i=0; i<data.posts.length; ++i) {
pids.push(data.posts[i].pid);
}
$(window).trigger('action:posts.loaded', pids);
onNewPostsLoaded(html, pids);
callback(true); callback(true);
}); });
} }
function onNewPostsLoaded(html, posts) { function onNewPostsLoaded(html, pids) {
var pids = [];
for(var i=0; i<posts.length; ++i) {
pids.push(posts[i].pid);
}
if (app.uid) { if (app.uid) {
socket.emit('posts.getPrivileges', pids, function(err, privileges) { socket.emit('posts.getPrivileges', pids, function(err, privileges) {
if(err) { if(err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
for(i=0; i<pids.length; ++i) { for(var i=0; i<pids.length; ++i) {
toggleModTools(pids[i], privileges[i]); toggleModTools(pids[i], privileges[i]);
} }
}); });
} else { } else {
for(i=0; i<pids.length; ++i) { for(var i=0; i<pids.length; ++i) {
toggleModTools(pids[i], {editable:false, move: false}); toggleModTools(pids[i], {editable: false, move: false});
} }
} }

Loading…
Cancel
Save