mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
topic watching
This commit is contained in:
@@ -83,12 +83,18 @@ define('forum/topic/threadTools', [
|
||||
deletePosts.init();
|
||||
fork.init();
|
||||
|
||||
components.get('topic').on('click', '[component="topic/follow"], [component="topic/unfollow"]', follow);
|
||||
components.get('topic/follow').off('click').on('click', follow);
|
||||
components.get('topic/unfollow').off('click').on('click', follow);
|
||||
$('.topic').on('click', '[component="topic/following"]', function() {
|
||||
setFollow('follow');
|
||||
});
|
||||
$('.topic').on('click', '[component="topic/reading"]', function() {
|
||||
setFollow('unfollow');
|
||||
});
|
||||
$('.topic').on('click', '[component="topic/ignoring"]', function() {
|
||||
setFollow('ignore');
|
||||
});
|
||||
|
||||
function follow() {
|
||||
socket.emit('topics.toggleFollow', tid, function(err, state) {
|
||||
function setFollow(type) {
|
||||
socket.emit('topics.changeWatching', {tid: tid, type: type}, function(err) {
|
||||
if (err) {
|
||||
return app.alert({
|
||||
type: 'danger',
|
||||
@@ -98,12 +104,19 @@ define('forum/topic/threadTools', [
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
setFollowState(state);
|
||||
var message = '';
|
||||
if (type === 'follow') {
|
||||
message = '[[topic:following_topic.message]]';
|
||||
} else if (type === 'unfollow') {
|
||||
message = '[[topic:not_following_topic.message]]';
|
||||
} else if (type === 'ignore') {
|
||||
message = '[[topic:ignoring_topic.message]]';
|
||||
}
|
||||
setFollowState(type);
|
||||
|
||||
app.alert({
|
||||
alert_id: 'follow_thread',
|
||||
message: state ? '[[topic:following_topic.message]]' : '[[topic:not_following_topic.message]]',
|
||||
message: message,
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
@@ -195,8 +208,17 @@ define('forum/topic/threadTools', [
|
||||
};
|
||||
|
||||
function setFollowState(state) {
|
||||
components.get('topic/follow').toggleClass('hidden', state);
|
||||
components.get('topic/unfollow').toggleClass('hidden', !state);
|
||||
var menu = components.get('topic/following/menu');
|
||||
menu.toggleClass('hidden', state !== 'follow');
|
||||
components.get('topic/following/check').toggleClass('fa-check', state === 'follow');
|
||||
|
||||
menu = components.get('topic/reading/menu');
|
||||
menu.toggleClass('hidden', state !== 'unfollow');
|
||||
components.get('topic/reading/check').toggleClass('fa-check', state === 'unfollow');
|
||||
|
||||
menu = components.get('topic/ignoring/menu');
|
||||
menu.toggleClass('hidden', state !== 'ignore' );
|
||||
components.get('topic/ignoring/check').toggleClass('fa-check', state === 'ignore');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user