Skip to content

Commit

Permalink
feat: #8695, allow sort for guests
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Sep 29, 2020
1 parent 7f58e3a commit ea0f326
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions public/src/modules/sort.js
Expand Up @@ -13,15 +13,24 @@ define('sort', ['components'], function (components) {
$('body')
.off('click', '[component="thread/sort"] a')
.on('click', '[component="thread/sort"] a', function () {
var newSetting = $(this).attr('data-sort');
socket.emit(method, newSetting, function (err) {
if (err) {
return app.alertError(err.message);
}
function refresh(newSetting, params) {
config[field] = newSetting;
var qs = decodeURIComponent($.param(utils.params()));
var qs = decodeURIComponent($.param(params));
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
});
}
var newSetting = $(this).attr('data-sort');
if (app.user.uid) {
socket.emit(method, newSetting, function (err) {
if (err) {
return app.alertError(err.message);
}
refresh(newSetting, utils.params());
});
} else {
var urlParams = utils.params();
urlParams.sort = newSetting;
refresh(newSetting, urlParams);
}
});
};

Expand Down

0 comments on commit ea0f326

Please sign in to comment.