diff --git a/web/app/common/constants.js b/web/app/common/constants.js index cc22d65d..a0d7d159 100644 --- a/web/app/common/constants.js +++ b/web/app/common/constants.js @@ -11,6 +11,7 @@ const PROVIDER_NAMES = { facebook: 'Facebook', github: 'GitHub', }; +const DEFAULT_SORT = '-score'; module.exports = { BASE_URL, @@ -22,4 +23,5 @@ module.exports = { DEFAULT_LAST_COMMENTS_MAX, DEFAULT_MAX_COMMENT_SIZE, PROVIDER_NAMES, + DEFAULT_SORT, }; diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index c8b37e2e..660f12bd 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -1,7 +1,7 @@ import { h, Component } from 'preact'; import api from 'common/api'; -import { BASE_URL, NODE_ID, COMMENT_NODE_CLASSNAME_PREFIX } from 'common/constants'; +import { BASE_URL, NODE_ID, COMMENT_NODE_CLASSNAME_PREFIX, DEFAULT_SORT } from 'common/constants'; import { url } from 'common/settings'; import store from 'common/store'; @@ -21,9 +21,9 @@ export default class Root extends Component { let sort; try { - sort = localStorage.getItem(LS_SORT_KEY); + sort = localStorage.getItem(LS_SORT_KEY) || DEFAULT_SORT; } catch(e) { - sort = '-score'; + sort = DEFAULT_SORT; } this.state = {