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

@ -60,6 +60,12 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel
} else if (!Move.tids) {
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({
alert_id: 'tids_move_' + (Move.tids ? Move.tids.join('-') : 'all'),
title: '[[topic:thread_tools.move]]',
@ -67,7 +73,7 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel
type: 'success',
timeout: 10000,
timeoutfn: function () {
moveTopics();
moveTopics(data);
},
clickfn: function (alert, params) {
delete params.timeoutfn;
@ -77,26 +83,19 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel
}
}
function moveTopics() {
var data = {
tids: Move.tids,
cid: selectedCategory.cid,
currentCid: Move.currentCid,
};
function moveTopics(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) {
return app.alertError(err.message);
}
if (typeof Move.onComplete === 'function') {
Move.onComplete();
if (typeof data.onComplete === 'function') {
data.onComplete();
}
});
}
return Move;
});

Loading…
Cancel
Save