diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js
index f107ba335e..3d1fe48075 100644
--- a/public/src/forum/topic.js
+++ b/public/src/forum/topic.js
@@ -612,7 +612,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
});
ajaxify.register_events([
- 'event:rep_up', 'event:rep_down', 'event:new_post', 'get_users_in_room',
+ 'event:rep_up', 'event:rep_down', 'event:favourited', 'event:unfavourited', 'event:new_post', 'get_users_in_room',
'event:topic_deleted', 'event:topic_restored', 'event:topic:locked',
'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned',
'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored',
@@ -714,6 +714,14 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
adjust_rep(-1, data.pid, data.uid);
});
+ socket.on('event:favourited', function(data) {
+ adjust_favourites(1, data.pid, data.uid);
+ });
+
+ socket.on('event:unfavourited', function(data) {
+ adjust_favourites(-1, data.pid, data.uid);
+ });
+
socket.on('event:new_post', function(data) {
if(config.usePagination) {
onNewPostPagination(data);
@@ -884,6 +892,15 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
reputationElements.html(reputation).attr('data-reputation', reputation);
}
+ function adjust_favourites(value, pid, uid) {
+ var favourites = $('li[data-pid="' + pid + '"] .favouriteCount'),
+ currentFavourites = parseInt(favourites.attr('data-favourites'), 10);
+
+ currentFavourites += value;
+
+ favourites.html(currentFavourites).attr('data-favourites', currentFavourites);
+ }
+
function set_locked_state(locked, alert) {
var threadReplyBtn = $('.topic-main-buttons .post_reply'),
postReplyBtns = document.querySelectorAll('#post-container .post_reply'),
diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl
index 4506f5d1d9..83d875acad 100644
--- a/public/templates/topic.tpl
+++ b/public/templates/topic.tpl
@@ -72,7 +72,7 @@