fix: , flag actions regression

isekai-main
Julian Lam
parent 3e5a0f0d68
commit fec907d99d

@ -83,15 +83,15 @@ define('forum/flags/detail', [
break; break;
case 'delete-post': case 'delete-post':
postAction('delete', ajaxify.data.target.pid, ajaxify.data.target.tid); postAction('delete', api.del, `/posts/${ajaxify.data.target.pid}/state`);
break; break;
case 'purge-post': case 'purge-post':
postAction('purge', ajaxify.data.target.pid, ajaxify.data.target.tid); postAction('purge', api.del, `/posts/${ajaxify.data.target.pid}`);
break; break;
case 'restore-post': case 'restore-post':
postAction('restore', ajaxify.data.target.pid, ajaxify.data.target.tid); postAction('restore', api.put, `/posts/${ajaxify.data.target.pid}/state`);
break; break;
case 'prepare-edit': { case 'prepare-edit': {
@ -115,23 +115,14 @@ define('forum/flags/detail', [
}); });
}; };
function postAction(action, pid, tid) { function postAction(action, method, path) {
translator.translate('[[topic:post_' + action + '_confirm]]', function (msg) { translator.translate('[[topic:post_' + action + '_confirm]]', function (msg) {
bootbox.confirm(msg, function (confirm) { bootbox.confirm(msg, function (confirm) {
if (!confirm) { if (!confirm) {
return; return;
} }
socket.emit('posts.' + action, { method(path).then(ajaxify.refresh).catch(alerts.error);
pid: pid,
tid: tid,
}, function (err) {
if (err) {
alerts.error(err);
}
ajaxify.refresh();
});
}); });
}); });
} }

Loading…
Cancel
Save