mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	watch unwatch
update on toggle, moved isFollowing to api return and template
This commit is contained in:
		| @@ -43,7 +43,9 @@ | |||||||
| 	"markAsUnreadForAll.success" : "Topic marked as unread for all.", | 	"markAsUnreadForAll.success" : "Topic marked as unread for all.", | ||||||
|  |  | ||||||
| 	"watch": "Watch", | 	"watch": "Watch", | ||||||
|  | 	"unwatch": "Unwatch", | ||||||
| 	"watch.title": "Be notified of new replies in this topic", | 	"watch.title": "Be notified of new replies in this topic", | ||||||
|  | 	"unwatch.title": "Stop watching this topic", | ||||||
| 	"share_this_post": "Share this Post", | 	"share_this_post": "Share this Post", | ||||||
|  |  | ||||||
| 	"thread_tools.title": "Topic Tools", | 	"thread_tools.title": "Topic Tools", | ||||||
|   | |||||||
| @@ -60,10 +60,6 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func | |||||||
|  |  | ||||||
| 		fork.init(); | 		fork.init(); | ||||||
|  |  | ||||||
| 		socket.emit('topics.followCheck', tid, function(err, state) { |  | ||||||
| 			setFollowState(state); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		$('.posts').on('click', '.follow', function() { | 		$('.posts').on('click', '.follow', function() { | ||||||
| 			socket.emit('topics.follow', tid, function(err, state) { | 			socket.emit('topics.follow', tid, function(err, state) { | ||||||
| 				if(err) { | 				if(err) { | ||||||
| @@ -149,10 +145,23 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func | |||||||
| 			}); | 			}); | ||||||
| 			$('.topic-title i.fa-thumb-tack').toggleClass('hide', !data.isPinned); | 			$('.topic-title i.fa-thumb-tack').toggleClass('hide', !data.isPinned); | ||||||
| 		} | 		} | ||||||
| 	} | 	}; | ||||||
|  |  | ||||||
| 	function setFollowState(state) { | 	function setFollowState(state) { | ||||||
| 		$('.posts .follow').toggleClass('btn-success', state).attr('title', state ? 'You are currently receiving updates to this topic' : 'Be notified of new replies in this topic'); | 		var title = state ? '[[topic:unwatch.title]]' : '[[topic:watch.title]]'; | ||||||
|  | 		var iconClass = state ? 'fa fa-eye-slash' : 'fa fa-eye'; | ||||||
|  | 		var text = state ? '[[topic:unwatch]]' : '[[topic:watch]]'; | ||||||
|  |  | ||||||
|  | 		var followEl = $('.posts .follow'); | ||||||
|  |  | ||||||
|  | 		translator.translate(title, function(titleTranslated) { | ||||||
|  | 			followEl.attr('title', titleTranslated).find('i').attr('class', iconClass); | ||||||
|  | 			followEl.find('span').text(text); | ||||||
|  |  | ||||||
|  | 			translator.translate(followEl.html(), function(translated) { | ||||||
|  | 				followEl.html(translated); | ||||||
|  | 			}); | ||||||
|  | 		}); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -199,7 +199,6 @@ Sockets.init = function(server) { | |||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
| 		socket.on('*', function(payload, callback) { | 		socket.on('*', function(payload, callback) { | ||||||
|  |  | ||||||
| 			function callMethod(method) { | 			function callMethod(method) { | ||||||
| 				method.call(null, socket, payload.args.length ? payload.args[0] : null, function(err, result) { | 				method.call(null, socket, payload.args.length ? payload.args[0] : null, function(err, result) { | ||||||
| 					if (callback) { | 					if (callback) { | ||||||
| @@ -279,10 +278,7 @@ Sockets.uidInRoom = function(uid, room) { | |||||||
|  |  | ||||||
| Sockets.getSocketCount = function() { | Sockets.getSocketCount = function() { | ||||||
| 	var clients = io.sockets.manager.rooms['']; | 	var clients = io.sockets.manager.rooms['']; | ||||||
| 	if (!Array.isArray(clients)) { | 	return Array.isArray(clients) ? clients.length : 0; | ||||||
| 		return 0; |  | ||||||
| 	} |  | ||||||
| 	return clients.length; |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| Sockets.getConnectedClients = function() { | Sockets.getConnectedClients = function() { | ||||||
|   | |||||||
| @@ -395,10 +395,6 @@ SocketTopics.moveAll = function(socket, data, callback) { | |||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketTopics.followCheck = function(socket, tid, callback) { |  | ||||||
| 	topics.isFollowing(tid, socket.uid, callback); |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| SocketTopics.follow = function(socket, tid, callback) { | SocketTopics.follow = function(socket, tid, callback) { | ||||||
| 	if(!socket.uid) { | 	if(!socket.uid) { | ||||||
| 		return callback(new Error('[[error:not-logged-in]]')); | 		return callback(new Error('[[error:not-logged-in]]')); | ||||||
|   | |||||||
| @@ -286,17 +286,21 @@ var async = require('async'), | |||||||
| 				}, | 				}, | ||||||
| 				tags: function(next) { | 				tags: function(next) { | ||||||
| 					Topics.getTopicTagsObjects(tid, next); | 					Topics.getTopicTagsObjects(tid, next); | ||||||
|  | 				}, | ||||||
|  | 				isFollowing: function(next) { | ||||||
|  | 					Topics.isFollowing(tid, uid, next); | ||||||
| 				} | 				} | ||||||
| 			}, function(err, results) { | 			}, function(err, results) { | ||||||
| 				if (err) { | 				if (err) { | ||||||
| 					return callback(err); | 					return callback(err); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				topicData.category = results.category; |  | ||||||
| 				topicData.posts = results.posts; | 				topicData.posts = results.posts; | ||||||
| 				topicData.tags = results.tags; | 				topicData.category = results.category; | ||||||
| 				topicData.thread_tools = results.threadTools; | 				topicData.thread_tools = results.threadTools; | ||||||
| 				topicData.pageCount = results.pageCount; | 				topicData.tags = results.tags; | ||||||
|  | 				topicData.isFollowing = results.isFollowing; | ||||||
|  |  | ||||||
| 				topicData.unreplied = parseInt(topicData.postcount, 10) === 1; | 				topicData.unreplied = parseInt(topicData.postcount, 10) === 1; | ||||||
| 				topicData.deleted = parseInt(topicData.deleted, 10) === 1; | 				topicData.deleted = parseInt(topicData.deleted, 10) === 1; | ||||||
| 				topicData.locked = parseInt(topicData.locked, 10) === 1; | 				topicData.locked = parseInt(topicData.locked, 10) === 1; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user