mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
categories constants moved to constants module
This commit is contained in:
parent
f788bd1d4d
commit
41fe043768
2 changed files with 16 additions and 13 deletions
|
|
@ -4,6 +4,8 @@ const CATALOG_PREVIEW_SIZE = 10;
|
|||
const CATALOG_PAGE_SIZE = 100;
|
||||
const NONE_EXTRA_VALUE = 'None';
|
||||
const SKIP_EXTRA_NAME = 'skip';
|
||||
const IMDB_LINK_CATEGORY = 'imdb';
|
||||
const SHARE_LINK_CATEGORY = 'share';
|
||||
const TYPE_PRIORITIES = {
|
||||
movie: 10,
|
||||
series: 9,
|
||||
|
|
@ -25,5 +27,7 @@ module.exports = {
|
|||
CATALOG_PAGE_SIZE,
|
||||
NONE_EXTRA_VALUE,
|
||||
SKIP_EXTRA_NAME,
|
||||
IMDB_LINK_CATEGORY,
|
||||
SHARE_LINK_CATEGORY,
|
||||
TYPE_PRIORITIES
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ const Button = require('stremio/common/Button');
|
|||
const Image = require('stremio/common/Image');
|
||||
const ModalDialog = require('stremio/common/ModalDialog');
|
||||
const SharePrompt = require('stremio/common/SharePrompt');
|
||||
const CONSTANTS = require('stremio/common/CONSTANTS');
|
||||
const routesRegexp = require('stremio/common/routesRegexp');
|
||||
const useBinaryState = require('stremio/common/useBinaryState');
|
||||
const ActionButton = require('./ActionButton');
|
||||
|
|
@ -15,8 +16,6 @@ const MetaLinks = require('./MetaLinks');
|
|||
const MetaPreviewPlaceholder = require('./MetaPreviewPlaceholder');
|
||||
const styles = require('./styles');
|
||||
|
||||
const IMDB_LINK_CATEGORY = 'imdb';
|
||||
const SHARE_LINK_CATEGORY = 'share';
|
||||
const ALLOWED_LINK_REDIRECTS = [
|
||||
routesRegexp.search.regexp,
|
||||
routesRegexp.discover.regexp,
|
||||
|
|
@ -30,12 +29,12 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
links
|
||||
.filter((link) => link && typeof link.category === 'string' && typeof link.url === 'string')
|
||||
.reduce((linksGroups, { category, name, url }) => {
|
||||
if (category === IMDB_LINK_CATEGORY) {
|
||||
if (category === CONSTANTS.IMDB_LINK_CATEGORY) {
|
||||
linksGroups[category] = {
|
||||
label: name,
|
||||
href: `https://www.stremio.com/warning#${encodeURIComponent(`https://www.imdb.com/title/${encodeURIComponent(url)}`)}`
|
||||
};
|
||||
} else if (category === SHARE_LINK_CATEGORY) {
|
||||
} else if (category === CONSTANTS.SHARE_LINK_CATEGORY) {
|
||||
linksGroups[category] = {
|
||||
label: name,
|
||||
href: url
|
||||
|
|
@ -96,7 +95,7 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
null
|
||||
}
|
||||
{
|
||||
(typeof releaseInfo === 'string' && releaseInfo.length > 0) || (released instanceof Date && !isNaN(released.getTime())) || (typeof runtime === 'string' && runtime.length > 0) || typeof linksGroups[IMDB_LINK_CATEGORY] === 'object' ?
|
||||
(typeof releaseInfo === 'string' && releaseInfo.length > 0) || (released instanceof Date && !isNaN(released.getTime())) || (typeof runtime === 'string' && runtime.length > 0) || typeof linksGroups[CONSTANTS.IMDB_LINK_CATEGORY] === 'object' ?
|
||||
<div className={styles['runtime-release-info-container']}>
|
||||
{
|
||||
typeof runtime === 'string' && runtime.length > 0 ?
|
||||
|
|
@ -114,16 +113,16 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
null
|
||||
}
|
||||
{
|
||||
typeof linksGroups[IMDB_LINK_CATEGORY] === 'object' ?
|
||||
typeof linksGroups[CONSTANTS.IMDB_LINK_CATEGORY] === 'object' ?
|
||||
<Button
|
||||
className={styles['imdb-button-container']}
|
||||
title={linksGroups[IMDB_LINK_CATEGORY].label}
|
||||
href={linksGroups[IMDB_LINK_CATEGORY].href}
|
||||
title={linksGroups[CONSTANTS.IMDB_LINK_CATEGORY].label}
|
||||
href={linksGroups[CONSTANTS.IMDB_LINK_CATEGORY].href}
|
||||
target={'_blank'}
|
||||
{...(compact ? { tabIndex: -1 } : null)}
|
||||
>
|
||||
<Icon className={styles['icon']} icon={'ic_imdbnoframe'} />
|
||||
<div className={styles['label']}>{linksGroups[IMDB_LINK_CATEGORY].label}</div>
|
||||
<div className={styles['label']}>{linksGroups[CONSTANTS.IMDB_LINK_CATEGORY].label}</div>
|
||||
</Button>
|
||||
:
|
||||
null
|
||||
|
|
@ -149,8 +148,8 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
{
|
||||
Object.keys(linksGroups)
|
||||
.filter((category) => {
|
||||
return category !== IMDB_LINK_CATEGORY &&
|
||||
category !== SHARE_LINK_CATEGORY;
|
||||
return category !== CONSTANTS.IMDB_LINK_CATEGORY &&
|
||||
category !== CONSTANTS.SHARE_LINK_CATEGORY;
|
||||
})
|
||||
.map((category, index) => (
|
||||
<MetaLinks
|
||||
|
|
@ -188,7 +187,7 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
null
|
||||
}
|
||||
{
|
||||
!compact && typeof linksGroups[SHARE_LINK_CATEGORY] === 'object' ?
|
||||
!compact && typeof linksGroups[CONSTANTS.SHARE_LINK_CATEGORY] === 'object' ?
|
||||
<React.Fragment>
|
||||
<ActionButton
|
||||
className={styles['action-button']}
|
||||
|
|
@ -202,7 +201,7 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
<ModalDialog title={'Share'} onCloseRequest={closeShareModal}>
|
||||
<SharePrompt
|
||||
className={styles['share-prompt']}
|
||||
url={linksGroups[SHARE_LINK_CATEGORY].href}
|
||||
url={linksGroups[CONSTANTS.SHARE_LINK_CATEGORY].href}
|
||||
/>
|
||||
</ModalDialog>
|
||||
:
|
||||
|
|
|
|||
Loading…
Reference in a new issue