mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
uses server-side bookmark if available
This commit is contained in:
@@ -116,7 +116,8 @@ define('forum/topic', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
function handleBookmark(tid) {
|
function handleBookmark(tid) {
|
||||||
var bookmark = localStorage.getItem('topic:' + tid + ':bookmark');
|
// use the user's bookmark data if available, fallback to local if available
|
||||||
|
var bookmark = ajaxify.data.bookmark || localStorage.getItem('topic:' + tid + ':bookmark');
|
||||||
var postIndex = getPostIndex();
|
var postIndex = getPostIndex();
|
||||||
|
|
||||||
if (postIndex && window.location.search.indexOf('page=') === -1) {
|
if (postIndex && window.location.search.indexOf('page=') === -1) {
|
||||||
@@ -198,10 +199,9 @@ define('forum/topic', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
var bookmarkKey = 'topic:' + ajaxify.data.tid + ':bookmark';
|
var bookmarkKey = 'topic:' + ajaxify.data.tid + ':bookmark';
|
||||||
var currentBookmark = localStorage.getItem(bookmarkKey);
|
var currentBookmark = ajaxify.data.bookmark || localStorage.getItem(bookmarkKey);
|
||||||
|
|
||||||
if (!currentBookmark || parseInt(postIndex, 10) > parseInt(currentBookmark, 10)) {
|
if (!currentBookmark || parseInt(postIndex, 10) > parseInt(currentBookmark, 10)) {
|
||||||
localStorage.setItem(bookmarkKey, postIndex);
|
|
||||||
if (app.user.uid) {
|
if (app.user.uid) {
|
||||||
var data = {
|
var data = {
|
||||||
'tid': ajaxify.data.tid,
|
'tid': ajaxify.data.tid,
|
||||||
@@ -209,6 +209,8 @@ define('forum/topic', [
|
|||||||
'postIndex': postIndex
|
'postIndex': postIndex
|
||||||
}
|
}
|
||||||
socket.emit('topics.bookmark', data);
|
socket.emit('topics.bookmark', data);
|
||||||
|
} else {
|
||||||
|
localStorage.setItem(bookmarkKey, postIndex);
|
||||||
}
|
}
|
||||||
app.removeAlert('bookmark');
|
app.removeAlert('bookmark');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,8 @@ var async = require('async'),
|
|||||||
category: async.apply(Topics.getCategoryData, tid),
|
category: async.apply(Topics.getCategoryData, tid),
|
||||||
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}),
|
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}),
|
||||||
tags: async.apply(Topics.getTopicTagsObjects, tid),
|
tags: async.apply(Topics.getTopicTagsObjects, tid),
|
||||||
isFollowing: async.apply(Topics.isFollowing, [tid], uid)
|
isFollowing: async.apply(Topics.isFollowing, [tid], uid),
|
||||||
|
bookmark: async.apply(Topics.getUserBookmark, tid, uid)
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
@@ -232,6 +233,7 @@ var async = require('async'),
|
|||||||
topicData.thread_tools = results.threadTools.tools;
|
topicData.thread_tools = results.threadTools.tools;
|
||||||
topicData.tags = results.tags;
|
topicData.tags = results.tags;
|
||||||
topicData.isFollowing = results.isFollowing[0];
|
topicData.isFollowing = results.isFollowing[0];
|
||||||
|
topicData.bookmark = results.bookmark;
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user