Added client-side support for browsing settings
This commit is contained in:
parent
4d7e035383
commit
64743499b6
1 changed files with 24 additions and 4 deletions
|
@ -10,6 +10,7 @@ App.Presenters.PostListPresenter = function(
|
||||||
api,
|
api,
|
||||||
keyboard,
|
keyboard,
|
||||||
pagerPresenter,
|
pagerPresenter,
|
||||||
|
browsingSettings,
|
||||||
topNavigationPresenter) {
|
topNavigationPresenter) {
|
||||||
|
|
||||||
var KEY_RETURN = 13;
|
var KEY_RETURN = 13;
|
||||||
|
@ -105,13 +106,32 @@ App.Presenters.PostListPresenter = function(
|
||||||
function renderPosts($page, posts) {
|
function renderPosts($page, posts) {
|
||||||
var $target = $page.find('.posts');
|
var $target = $page.find('.posts');
|
||||||
_.each(posts, function(post) {
|
_.each(posts, function(post) {
|
||||||
|
if (!shouldSkipPost(post)) {
|
||||||
var $post = renderPost(post);
|
var $post = renderPost(post);
|
||||||
softRenderPost($post);
|
softRenderPost($post);
|
||||||
$target.append($post);
|
$target.append($post);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
windowResized();
|
windowResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldSkipPost(post) {
|
||||||
|
var settings = browsingSettings.getSettings();
|
||||||
|
if (post.ownScore < 0 && settings.hideDownvoted) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (settings.listPosts) {
|
||||||
|
if (post.safety === 'safe' && !settings.listPosts.safe) {
|
||||||
|
return true;
|
||||||
|
} else if (post.safety === 'sketchy' && !settings.listPosts.sketchy) {
|
||||||
|
return true;
|
||||||
|
} else if (post.safety === 'unsafe' && !settings.listPosts.unsafe) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function renderPost(post) {
|
function renderPost(post) {
|
||||||
var $post = jQuery('<li>' + templates.listItem({
|
var $post = jQuery('<li>' + templates.listItem({
|
||||||
util: util,
|
util: util,
|
||||||
|
@ -212,4 +232,4 @@ App.Presenters.PostListPresenter = function(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.register('postListPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'api', 'keyboard', 'pagerPresenter', 'topNavigationPresenter'], App.Presenters.PostListPresenter);
|
App.DI.register('postListPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'api', 'keyboard', 'pagerPresenter', 'browsingSettings', 'topNavigationPresenter'], App.Presenters.PostListPresenter);
|
||||||
|
|
Loading…
Reference in a new issue