mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
refactor: topic mark read/unread routes
This commit is contained in:
@@ -60,6 +60,28 @@ define('forum/topic/threadTools', [
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/mark-unread"]', function () {
|
||||
topicCommand('del', '/read', undefined, () => {
|
||||
if (app.previousUrl && !app.previousUrl.match('^/topic')) {
|
||||
ajaxify.go(app.previousUrl, function () {
|
||||
handleBack.onBackClicked(true);
|
||||
});
|
||||
} else if (ajaxify.data.category) {
|
||||
ajaxify.go('category/' + ajaxify.data.category.slug, handleBack.onBackClicked);
|
||||
}
|
||||
|
||||
alerts.success('[[topic:mark_unread.success]]');
|
||||
});
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/mark-unread-for-all"]', function () {
|
||||
const btn = $(this);
|
||||
topicCommand('put', '/bump', undefined, () => {
|
||||
alerts.success('[[topic:markAsUnreadForAll.success]]');
|
||||
btn.parents('.thread-tools.open').find('.dropdown-toggle').trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/event/delete"]', function () {
|
||||
const eventId = $(this).attr('data-topic-event-id');
|
||||
const eventEl = $(this).parents('[component="topic/event"]');
|
||||
@@ -74,38 +96,6 @@ define('forum/topic/threadTools', [
|
||||
});
|
||||
});
|
||||
|
||||
// todo: should also use topicCommand, but no write api call exists for this yet
|
||||
topicContainer.on('click', '[component="topic/mark-unread"]', function () {
|
||||
socket.emit('topics.markUnread', tid, function (err) {
|
||||
if (err) {
|
||||
return alerts.error(err);
|
||||
}
|
||||
|
||||
if (app.previousUrl && !app.previousUrl.match('^/topic')) {
|
||||
ajaxify.go(app.previousUrl, function () {
|
||||
handleBack.onBackClicked(true);
|
||||
});
|
||||
} else if (ajaxify.data.category) {
|
||||
ajaxify.go('category/' + ajaxify.data.category.slug, handleBack.onBackClicked);
|
||||
}
|
||||
|
||||
alerts.success('[[topic:mark_unread.success]]');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/mark-unread-for-all"]', function () {
|
||||
const btn = $(this);
|
||||
socket.emit('topics.markAsUnreadForAll', [tid], function (err) {
|
||||
if (err) {
|
||||
return alerts.error(err);
|
||||
}
|
||||
alerts.success('[[topic:markAsUnreadForAll.success]]');
|
||||
btn.parents('.thread-tools.open').find('.dropdown-toggle').trigger('click');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/move"]', function () {
|
||||
require(['forum/topic/move'], function (move) {
|
||||
move.init([tid], ajaxify.data.cid);
|
||||
|
||||
Reference in New Issue
Block a user