From 27ccbb6eef611ded4c8dd6ae161345b42f9e0343 Mon Sep 17 00:00:00 2001 From: Danny August Ramaputra Date: Sat, 6 Feb 2021 20:00:29 +1000 Subject: [PATCH] refactor: improved unavailable cast error response --- cast-fe/src/views/Scene.jsx | 575 +++++++++++++++++++----------------- 1 file changed, 303 insertions(+), 272 deletions(-) diff --git a/cast-fe/src/views/Scene.jsx b/cast-fe/src/views/Scene.jsx index c1f1776..5988a21 100644 --- a/cast-fe/src/views/Scene.jsx +++ b/cast-fe/src/views/Scene.jsx @@ -52,6 +52,7 @@ class Scene extends Component { comments: [], error_comment: "", not_found: false, + not_loadable: false, }; this.handleDownload = this.handleDownload.bind(this); this.handleShare = this.handleShare.bind(this); @@ -160,7 +161,10 @@ class Scene extends Component { }) .catch((error) => { console.log(error); - this.setState({ loading: { ...this.state.loading, current: false } }); + this.setState({ + not_loadable: true, + loading: { ...this.state.loading, current: false }, + }); }); } @@ -289,298 +293,325 @@ class Scene extends Component { if (this.state.loading.live) return <>; return ( <> - {!this.state.not_found && !this.state.offline && ( - - - - - - - - -
- {this.state.live && - Object.values(this.state.live).map((video) => ( - - this.incrementView(a, b)} - /> - - ))} - {this.state.loading.live && ( - - )} -
- - - - - - {this.state.video?.unlisted && ( - - Unlisted - + {!this.state.not_found && + !this.state.not_loadable && + !this.state.offline && ( + + + + + + + + +
+ {this.state.live && + Object.values(this.state.live).map((video) => ( + + this.incrementView(a, b)} + /> + + ))} + {this.state.loading.live && ( + )} - {this.state.video?.tags && - Object.values(this.state.video?.tags).map((tag) => ( - - {tag} +
+ + + + + + {this.state.video?.unlisted && ( + + Unlisted - ))} - - - {this.state.video?.type === VIDEO_TYPE_VOD && ( + )} + {this.state.video?.tags && + Object.values(this.state.video?.tags).map((tag) => ( + + {tag} + + ))} + + + {this.state.video?.type === VIDEO_TYPE_VOD && ( + + get_app download + + )} - get_app download + share share - )} - - share share - - - - thumb_up - {" "} - {`${abbreviate().number(this.state.likes) || 0} like${ - this.state.likes === 1 ? "" : "s" - }`} - - - remove_red_eye{" "} - {abbreviate().number(this.state.video?.views) || 0}{" "} - {this.state.video?.type === VIDEO_TYPE_LIVE - ? "viewers" - : "views"} - - - -

{this.state.video?.title}

-

- {format().date(this.state.video?.created_at)} -

-
-
- -
-

- {this.state.video?.author.name} -

-

- {abbreviate().number( - this.state.video?.author.subscribers - ) || 0}{" "} - subscriber - {this.state.video?.author.subscribers !== 1 && "s"} -

+ + thumb_up + {" "} + {`${abbreviate().number(this.state.likes) || 0} like${ + this.state.likes === 1 ? "" : "s" + }`} + + + remove_red_eye{" "} + {abbreviate().number(this.state.video?.views) || 0}{" "} + {this.state.video?.type === VIDEO_TYPE_LIVE + ? "viewers" + : "views"} + + + +

{this.state.video?.title}

+

+ {format().date(this.state.video?.created_at)} +

+
+
+ +
+

+ {this.state.video?.author.name} +

+

+ {abbreviate().number( + this.state.video?.author.subscribers + ) || 0}{" "} + subscriber + {this.state.video?.author.subscribers !== 1 && "s"} +

+
-
-
- -
-
- - -
- {this.state.video?.description} +
+
- - -
-

Comments

- - -
- {this.state.error_submit && ( - - {this.state.error_submit} - - )} - - - - - - - - {this.state.error_comment} - - - -
-
- {this.state.comments ? ( - Object.values(this.state.comments).map((comment) => { - return ( -
- +
+ + +
+ {this.state.video?.description} +
+ +
+
+

Comments

+ + +
+ {this.state.error_submit && ( + + {this.state.error_submit} + + )} + + + + + + + + {this.state.error_comment} + + + +
+
+ {this.state.comments ? ( + Object.values(this.state.comments).map((comment) => { + return (
-

- {comment.author.name} -

-

- -

-

+

- {comment.content} -

+

+ {comment.author.name} +

+

+ +

+

+ {comment.content} +

+
-
- ); - }) - ) : ( -
Post the first comment!
- )} -
- -
- -
-
- - - -
- {this.state.vod && - Object.values(this.state.vod).map((video) => ( - - this.incrementView(a, b)} - /> - - ))} - {this.state.loading.vod && ( - - )} -
- - - - )} + ); + }) + ) : ( +
Post the first comment!
+ )} +
+ +
+ +
+
+ + + +
+ {this.state.vod && + Object.values(this.state.vod).map((video) => ( + + this.incrementView(a, b)} + /> + + ))} + {this.state.loading.vod && ( + + )} +
+ + + + )} {this.state.not_found && ( <> {"Video +

+ Cast Not Found +

+ + )} + {this.state.not_loadable && ( + <> + {"Currently - Video Unavailable + Currently Unavailable )}