From c19d04f83eb0126af2b2028549afa6e9f8448497 Mon Sep 17 00:00:00 2001 From: btzr-io Date: Fri, 8 May 2020 22:24:02 -0500 Subject: [PATCH] fix comic-book content-type detection always show viewer: fix #4141 minor improvements for loading indicator --- ui/component/viewers/comicBookViewer.jsx | 4 ++-- ui/constants/claim.js | 9 +++++++++ ui/constants/file_render_modes.js | 1 - ui/redux/selectors/content.js | 5 +++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/component/viewers/comicBookViewer.jsx b/ui/component/viewers/comicBookViewer.jsx index 05ca41c87..419ec0eb8 100644 --- a/ui/component/viewers/comicBookViewer.jsx +++ b/ui/component/viewers/comicBookViewer.jsx @@ -50,12 +50,12 @@ const ComicBookViewer = (props: Props) => { }; const { error, loading, content } = finalSource; - const ready = content !== null && !loading; + const ready = content !== null && !loading && !error; const errorMessage = __("Sorry, looks like we can't load the archive."); return (
- {loading && } + {loading && } {ready && ( )} diff --git a/ui/constants/claim.js b/ui/constants/claim.js index d6486d553..651df6d53 100644 --- a/ui/constants/claim.js +++ b/ui/constants/claim.js @@ -22,3 +22,12 @@ export const FORCE_CONTENT_TYPE_PLAYER = [ 'application/x-ext-ogg', 'application/x-ext-m4a', ]; + +export const FORCE_CONTENT_TYPE_COMIC = [ + 'application/vnd.comicbook+zip', + 'application/vnd.comicbook-rar', + 'application/x-cbr', + 'application/x-cbt', + 'application/x-cbz', + 'application/x-cb7', +]; diff --git a/ui/constants/file_render_modes.js b/ui/constants/file_render_modes.js index 0840405d9..2fbe977bc 100644 --- a/ui/constants/file_render_modes.js +++ b/ui/constants/file_render_modes.js @@ -27,7 +27,6 @@ export const APPLICATION = 'application'; export const UNSUPPORTED = 'unsupported'; // PDFs disabled on desktop until we update Electron: https://github.com/electron/electron/issues/12337 -// Comics disabled because nothing is actually reporting as a comic type export const UNSUPPORTED_IN_THIS_APP = IS_WEB ? [CAD, COMIC, APPLICATION] : [APPLICATION, PDF]; export const UNRENDERABLE_MODES = Array.from( diff --git a/ui/redux/selectors/content.js b/ui/redux/selectors/content.js index b46a575cb..ec61391e5 100644 --- a/ui/redux/selectors/content.js +++ b/ui/redux/selectors/content.js @@ -20,7 +20,7 @@ import { selectAllCostInfoByUri, makeSelectCostInfoForUri } from 'lbryinc'; import { selectShowMatureContent } from 'redux/selectors/settings'; import * as RENDER_MODES from 'constants/file_render_modes'; import path from 'path'; -import { FORCE_CONTENT_TYPE_PLAYER } from 'constants/claim'; +import { FORCE_CONTENT_TYPE_PLAYER, FORCE_CONTENT_TYPE_COMIC } from 'constants/claim'; // @if TARGET='web' import { generateStreamUrl } from 'util/lbrytv'; // @endif @@ -212,7 +212,8 @@ export const makeSelectFileRenderModeForUri = (uri: string) => if (['3D-file', 'model'].includes(mediaType)) { return RENDER_MODES.CAD; } - if (mediaType === 'comic-book') { + // Force content type for fallback support of older claims + if (mediaType === 'comic-book' || FORCE_CONTENT_TYPE_COMIC.includes(contentType)) { return RENDER_MODES.COMIC; } if (