stores the user's bookmark on the server

This commit is contained in:
bdharrington7
2015-07-21 21:20:13 +08:00
parent 0bc4799c3c
commit 45df5a3d0b
3 changed files with 25 additions and 3 deletions

View File

@@ -197,10 +197,19 @@ define('forum/topic', [
}
}
var currentBookmark = localStorage.getItem('topic:' + ajaxify.data.tid + ':bookmark');
var bookmarkKey = 'topic:' + ajaxify.data.tid + ':bookmark';
var currentBookmark = localStorage.getItem(bookmarkKey);
if (!currentBookmark || parseInt(postIndex, 10) >= parseInt(currentBookmark, 10)) {
localStorage.setItem('topic:' + ajaxify.data.tid + ':bookmark', postIndex);
if (!currentBookmark || parseInt(postIndex, 10) > parseInt(currentBookmark, 10)) {
localStorage.setItem(bookmarkKey, postIndex);
if (app.user.uid) {
var data = {
'tid': ajaxify.data.tid,
'uid': app.user.uid,
'postIndex': postIndex
}
socket.emit('topics.bookmark', data);
}
app.removeAlert('bookmark');
}