diff --git a/src/common/CONSTANTS.js b/src/common/CONSTANTS.js index 359c5a3fb..ad5454bcf 100644 --- a/src/common/CONSTANTS.js +++ b/src/common/CONSTANTS.js @@ -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 }; diff --git a/src/common/MetaPreview/MetaPreview.js b/src/common/MetaPreview/MetaPreview.js index 557f76331..1b3219123 100644 --- a/src/common/MetaPreview/MetaPreview.js +++ b/src/common/MetaPreview/MetaPreview.js @@ -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' ?
{ 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' ? : 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) => ( :