Add setting for preferred default comment sorting
This commit is contained in:
parent
1fbef42a7c
commit
4ff7152be1
|
@ -18,12 +18,14 @@ function resetPreferences(res) {
|
|||
res.clearCookie('videos_muted');
|
||||
res.clearCookie('prefer_frontpage');
|
||||
res.clearCookie('show_large_gallery_images');
|
||||
res.clearCookie('default_comment_sort');
|
||||
}
|
||||
|
||||
preferenceRoutes.get('/preferences', (req, res, next) => {
|
||||
return res.render('preferences', {
|
||||
user_preferences: req.cookies,
|
||||
instance_config: config,
|
||||
comment_sort_values: ['best', 'top', 'new', 'controversial', 'old', 'qa'],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -93,6 +95,7 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => {
|
|||
let videos_muted = req.body.videos_muted;
|
||||
let prefer_frontpage = req.body.prefer_frontpage;
|
||||
let show_large_gallery_images = req.body.show_large_gallery_images;
|
||||
let default_comment_sort = req.body.default_comment_sort;
|
||||
|
||||
res.cookie('theme', theme, {
|
||||
maxAge: 365 * 24 * 60 * 60 * 1000,
|
||||
|
@ -182,6 +185,11 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => {
|
|||
httpOnly: true,
|
||||
});
|
||||
|
||||
res.cookie('default_comment_sort', default_comment_sort, {
|
||||
maxAge: 365 * 24 * 60 * 60 * 1000,
|
||||
httpOnly: true,
|
||||
});
|
||||
|
||||
return res.redirect('/preferences');
|
||||
});
|
||||
|
||||
|
|
|
@ -600,7 +600,7 @@ subredditRoutes.get(
|
|||
let subreddit = req.params.subreddit;
|
||||
let id = req.params.id;
|
||||
let snippet = encodeURIComponent(req.params.snippet);
|
||||
let sortby = req.query.sort;
|
||||
let sortby = req.query.sort || req.cookies.default_comment_sort;
|
||||
let comment_id = '';
|
||||
let viewing_comment = false;
|
||||
let comment_ids = req.query.comment_ids;
|
||||
|
|
|
@ -111,6 +111,17 @@ html
|
|||
input(type="checkbox", name="prefer_frontpage", id="prefer_frontpage", checked="checked")
|
||||
else
|
||||
input(type="checkbox", name="prefer_frontpage", id="prefer_frontpage")
|
||||
.setting
|
||||
label(for="default_comment_sort") Default comment sorting:
|
||||
select(id="default_comment_sort", name="default_comment_sort")
|
||||
-
|
||||
let default_comment_sort_html = ''
|
||||
let user_default_sort = user_preferences.default_comment_sort || 'best'
|
||||
|
||||
for(let key of comment_sort_values) {
|
||||
default_comment_sort_html += `<option value="${key}" ${(user_default_sort == key ? "selected" : "")}>${key == 'qa' ? 'Q&A' : key}</option>`
|
||||
}
|
||||
!= default_comment_sort_html
|
||||
legend Media
|
||||
.setting
|
||||
label(for="videos_muted") Mute videos by default:
|
||||
|
|
Loading…
Reference in New Issue