fix: #9136, fix move topic/post timeout errors

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 34ccabe3ab
commit 2ef72a94c2

@ -30,12 +30,18 @@ define('forum/topic/move-post', [
postSelect.togglePostSelection(postEl, postEl.attr('data-pid')); postSelect.togglePostSelection(postEl, postEl.attr('data-pid'));
} }
$(window).off('action:axajify.end', checkMoveButtonEnable) $(window).off('action:ajaxify.end', checkMoveButtonEnable)
.on('action:ajaxify.end', checkMoveButtonEnable); .on('action:ajaxify.end', checkMoveButtonEnable);
moveCommit.on('click', function () { moveCommit.on('click', function () {
if (!ajaxify.data.template.topic || !ajaxify.data.tid) {
return;
}
moveCommit.attr('disabled', true); moveCommit.attr('disabled', true);
var data = {
pids: postSelect.pids.slice(),
tid: ajaxify.data.tid,
};
alerts.alert({ alerts.alert({
alert_id: 'pids_move_' + postSelect.pids.join('-'), alert_id: 'pids_move_' + postSelect.pids.join('-'),
title: '[[topic:thread_tools.move-posts]]', title: '[[topic:thread_tools.move-posts]]',
@ -43,7 +49,7 @@ define('forum/topic/move-post', [
type: 'success', type: 'success',
timeout: 10000, timeout: 10000,
timeoutfn: function () { timeoutfn: function () {
movePosts(); movePosts(data);
}, },
clickfn: function (alert, params) { clickfn: function (alert, params) {
delete params.timeoutfn; delete params.timeoutfn;
@ -90,15 +96,15 @@ define('forum/topic/move-post', [
checkMoveButtonEnable(); checkMoveButtonEnable();
} }
function movePosts() { function movePosts(data) {
if (!ajaxify.data.template.topic || !ajaxify.data.tid) { if (!ajaxify.data.template.topic || !data.tid) {
return; return;
} }
socket.emit('posts.movePosts', { pids: postSelect.pids, tid: ajaxify.data.tid }, function (err) { socket.emit('posts.movePosts', { pids: data.pids, tid: data.tid }, function (err) {
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
postSelect.pids.forEach(function (pid) { data.pids.forEach(function (pid) {
components.get('post', 'pid', pid).fadeOut(500, function () { components.get('post', 'pid', pid).fadeOut(500, function () {
$(this).remove(); $(this).remove();
}); });
@ -116,6 +122,5 @@ define('forum/topic/move-post', [
} }
} }
return MovePost; return MovePost;
}); });

@ -60,6 +60,12 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel
} else if (!Move.tids) { } else if (!Move.tids) {
message = '[[topic:topic_move_all_success, ' + selectedCategory.name + ']]'; message = '[[topic:topic_move_all_success, ' + selectedCategory.name + ']]';
} }
var data = {
tids: Move.tids ? Move.tids.slice() : null,
cid: selectedCategory.cid,
currentCid: Move.currentCid,
onComplete: Move.onComplete,
};
alerts.alert({ alerts.alert({
alert_id: 'tids_move_' + (Move.tids ? Move.tids.join('-') : 'all'), alert_id: 'tids_move_' + (Move.tids ? Move.tids.join('-') : 'all'),
title: '[[topic:thread_tools.move]]', title: '[[topic:thread_tools.move]]',
@ -67,7 +73,7 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel
type: 'success', type: 'success',
timeout: 10000, timeout: 10000,
timeoutfn: function () { timeoutfn: function () {
moveTopics(); moveTopics(data);
}, },
clickfn: function (alert, params) { clickfn: function (alert, params) {
delete params.timeoutfn; delete params.timeoutfn;
@ -77,26 +83,19 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel
} }
} }
function moveTopics() { function moveTopics(data) {
var data = {
tids: Move.tids,
cid: selectedCategory.cid,
currentCid: Move.currentCid,
};
$(window).trigger('action:topic.move', data); $(window).trigger('action:topic.move', data);
socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', data, function (err) { socket.emit(!data.tids ? 'topics.moveAll' : 'topics.move', data, function (err) {
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
if (typeof Move.onComplete === 'function') { if (typeof data.onComplete === 'function') {
Move.onComplete(); data.onComplete();
} }
}); });
} }
return Move; return Move;
}); });

Loading…
Cancel
Save