Files
remark42/frontend/app/common/settings.ts
T
Pavel MineevandGitHub 85c71716f9 Small refactoring (#609)
* Move visibility param from redux store to local state

* use func for parsing location.search

* Remove bad wrapper

* we already have wrapper with NODE_ID on page and we shouldn't another one with the same id on page
* move common part of markup to level up

* Tinny refac of setSorting

* add dummy types for pollyfils

also, a bit rewrited way to resolve imports

* Move sort flag to local store

Because we don't need to share this param between diffrent parts of interface

* Add action creators

* move action to action creators

* Remove unused functions

* Merge in conditions in one

* One way for export API methods

* add default tags

* Rewrited changing read only mode

* removed unused function

* set sort changes

* always send sort from store
* rollback if sort don't  work

* constanst

* add typing
* shorten export
* remove double define of host
2020-03-07 12:25:18 -06:00

34 lines
1.1 KiB
TypeScript

import { Theme } from './types';
import { THEMES, MAX_SHOWN_ROOT_COMMENTS } from './constants';
import parseQuery from '@app/utils/parseQuery';
export interface QuerySettingsType {
site_id?: string;
page_title?: string;
url?: string;
max_shown_comments?: number;
theme: Theme;
/* used in delete users data page */
token?: string;
}
export const querySettings: Partial<QuerySettingsType> = parseQuery();
if (querySettings.max_shown_comments) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
querySettings.max_shown_comments = parseInt((querySettings.max_shown_comments as any) as string, 10);
} else {
querySettings.max_shown_comments = MAX_SHOWN_ROOT_COMMENTS;
}
if (!querySettings.theme || THEMES.indexOf(querySettings.theme) === -1) {
querySettings.theme = THEMES[0];
}
export const siteId = querySettings.site_id;
export const pageTitle = querySettings.page_title;
export const url = querySettings.url;
export const maxShownComments = querySettings.max_shown_comments;
export const token = querySettings.token;
export const theme = querySettings.theme;