mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 02:36:16 +01:00
on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues
This commit is contained in:
@@ -63,6 +63,7 @@ $(document).ready(function() {
|
|||||||
if (cache.get(url)) { return true; }
|
if (cache.get(url)) { return true; }
|
||||||
else {
|
else {
|
||||||
cache.url = ajaxify.currentPage;
|
cache.url = ajaxify.currentPage;
|
||||||
|
ajaxify.isPopState = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(window).off('scroll');
|
$(window).off('scroll');
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'],
|
|||||||
});
|
});
|
||||||
|
|
||||||
Unread.init = function() {
|
Unread.init = function() {
|
||||||
|
var topicsContainer = $('#topics-container');
|
||||||
|
|
||||||
app.enterRoom('recent_posts');
|
app.enterRoom('recent_posts');
|
||||||
|
|
||||||
$('#new-topics-alert').on('click', function() {
|
$('#new-topics-alert').on('click', function() {
|
||||||
@@ -42,7 +44,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'],
|
|||||||
|
|
||||||
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
||||||
|
|
||||||
$('#topics-container').empty();
|
topicsContainer.empty();
|
||||||
$('#category-no-topics').removeClass('hidden');
|
$('#category-no-topics').removeClass('hidden');
|
||||||
$('.markread').addClass('hidden');
|
$('.markread').addClass('hidden');
|
||||||
});
|
});
|
||||||
@@ -68,11 +70,22 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'],
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
topicsContainer.on('click', '.topic-title, .replies a', function(e) {
|
||||||
|
var tid = $(e.target).parents('[data-tid]').attr('data-tid');
|
||||||
|
socket.emit('topics.markAsRead', [tid], function(err) {
|
||||||
|
if(err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
doneRemovingTids([tid]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
socket.emit('categories.get', onCategoriesLoaded);
|
socket.emit('categories.get', onCategoriesLoaded);
|
||||||
|
|
||||||
topicSelect.init();
|
topicSelect.init();
|
||||||
|
|
||||||
if ($("body").height() <= $(window).height() && $('#topics-container').children().length >= 20) {
|
if ($("body").height() <= $(window).height() && topicsContainer.children().length >= 20) {
|
||||||
$('#load-more-btn').show();
|
$('#load-more-btn').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,16 +96,16 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'],
|
|||||||
infinitescroll.init(loadMoreTopics);
|
infinitescroll.init(loadMoreTopics);
|
||||||
|
|
||||||
function loadMoreTopics(direction) {
|
function loadMoreTopics(direction) {
|
||||||
if(direction < 0 || !$('#topics-container').length) {
|
if(direction < 0 || !topicsContainer.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
infinitescroll.loadMore('topics.loadMoreUnreadTopics', {
|
infinitescroll.loadMore('topics.loadMoreUnreadTopics', {
|
||||||
after: $('#topics-container').attr('data-nextstart')
|
after: topicsContainer.attr('data-nextstart')
|
||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
recent.onTopicsLoaded('unread', data.topics, true, done);
|
recent.onTopicsLoaded('unread', data.topics, true, done);
|
||||||
$('#topics-container').attr('data-nextstart', data.nextStart);
|
topicsContainer.attr('data-nextstart', data.nextStart);
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
$('#load-more-btn').hide();
|
$('#load-more-btn').hide();
|
||||||
@@ -101,10 +114,10 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'],
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function doneRemovingTids(tids) {
|
function doneRemovingTids(tids, quiet) {
|
||||||
removeTids(tids);
|
removeTids(tids);
|
||||||
|
|
||||||
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
if (!quiet) { app.alertSuccess('[[unread:topics_marked_as_read.success]]'); }
|
||||||
|
|
||||||
if (!$('#topics-container').children().length) {
|
if (!$('#topics-container').children().length) {
|
||||||
$('#category-no-topics').removeClass('hidden');
|
$('#category-no-topics').removeClass('hidden');
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ define('ajaxifyCache', function() {
|
|||||||
Cache.get = function(url) {
|
Cache.get = function(url) {
|
||||||
if (url === Cache.url && ajaxify.isPopState) {
|
if (url === Cache.url && ajaxify.isPopState) {
|
||||||
// Swap DOM elements
|
// Swap DOM elements
|
||||||
setTimeout(function() {
|
// setTimeout(function() {
|
||||||
Cache.tempDOM = $('#content > *').detach();
|
Cache.tempDOM = $('#content > *').detach();
|
||||||
$('#content').append(Cache.DOM);
|
$('#content').append(Cache.DOM);
|
||||||
Cache.DOM = Cache.tempDOM;
|
Cache.DOM = Cache.tempDOM;
|
||||||
}, 100); // 100ms for realism! :sunglasses:
|
// }, 100); // 100ms for realism! :sunglasses:
|
||||||
|
|
||||||
// Set the values that normally get set on ajaxify
|
// Set the values that normally get set on ajaxify
|
||||||
Cache.url = ajaxify.currentPage;
|
Cache.url = ajaxify.currentPage;
|
||||||
|
|||||||
Reference in New Issue
Block a user