Files
remark42/frontend/app/common/constants.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

59 lines
1.7 KiB
TypeScript

import { Sorting, AuthProvider, Theme } from './types';
export { BASE_URL, API_BASE, NODE_ID, COMMENT_NODE_CLASSNAME_PREFIX } from './constants.config';
export const LAST_COMMENTS_NODE_CLASSNAME = 'remark42__last-comments';
export const MAX_SHOWN_ROOT_COMMENTS = 10;
export const DEFAULT_SORT: Sorting = '-active';
/* matches auth providers to UI label */
export const PROVIDER_NAMES: { [P in AuthProvider['name']]: string } = {
google: 'Google',
twitter: 'Twitter',
facebook: 'Facebook',
github: 'GitHub',
yandex: 'Yandex',
dev: 'Dev',
anonymous: 'Anonymous',
email: 'Email',
};
/** locastorage key for collapsed comments */
export const LS_COLLAPSE_KEY = '__remarkCollapsed';
/** locastorage key for hidden users */
export const LS_HIDDEN_USERS_KEY = '__remarkHiddenUsers';
/** localstorage key under which sort preference resides */
export const LS_SORT_KEY = '__remarkSort';
export const THEMES: Theme[] = ['light', 'dark'];
export const IS_MOBILE = /Android|webOS|iPhone|iPad|iPod|Opera Mini|Windows Phone/i.test(navigator.userAgent);
/**
* Defines if browser storage features (cookies, localsrotage)
* are available or blocked via browser preferences
*/
export const IS_STORAGE_AVAILABLE: boolean = (() => {
try {
localStorage.setItem('localstorage_availability_test', '');
localStorage.removeItem('localstorage_availability_test');
} catch (e) {
return false;
}
return true;
})();
/**
* Defines whether iframe loaded in cross origin environment
* Usefull for checking if some privacy restriction may be applied
*/
export const IS_THIRD_PARTY: boolean = (() => {
try {
return window.parent.location.host !== window.location.host;
} catch (e) {
return true;
}
})();