From 6910f37c3b15f2a4ffaee9222f6df75c3652e936 Mon Sep 17 00:00:00 2001 From: Wes Weitzel Date: Sun, 1 Oct 2023 10:32:10 -0700 Subject: [PATCH] Dont use cloudfront if running local (#50) Also move api folder into lib folder --- README.md | 2 +- src/components/Video.tsx | 31 +++++++++++++++++++++---------- src/{ => lib}/api/core.ts | 0 src/{ => lib}/api/goals.ts | 0 src/{ => lib}/api/teams.ts | 0 src/lib/utils.ts | 4 ++++ src/pages/Goal.tsx | 2 +- src/pages/Goals.tsx | 6 +++--- 8 files changed, 30 insertions(+), 15 deletions(-) rename src/{ => lib}/api/core.ts (100%) rename src/{ => lib}/api/goals.ts (100%) rename src/{ => lib}/api/teams.ts (100%) diff --git a/README.md b/README.md index 21e8923..e1ce08a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # top90-frontend -Top90 is a website that populates with soccer goals in real time as they happen around the world +top90 is a website that populates with soccer goals in real time as they happen around the world https://top90.io diff --git a/src/components/Video.tsx b/src/components/Video.tsx index 6e9d69b..2ddcdc7 100644 --- a/src/components/Video.tsx +++ b/src/components/Video.tsx @@ -1,7 +1,8 @@ -import {Goal} from '../api/goals'; -import {API_BASE_URL} from '../api/core'; +import {Goal} from '../lib/api/goals'; +import {API_BASE_URL} from '../lib/api/core'; import {useEffect, useState} from 'react'; +import {cloudfrontEnabled} from '../lib/utils'; const buttonStyle = { border: 'none', @@ -70,19 +71,29 @@ export function Video({goal}: {goal: Goal}) { return 'https://s3-redditsoccergoals.top90.io/' + s3Key; } + function thumbnailUrl(goal: Goal) { + if (cloudfrontEnabled()) { + return cloudfrontUrl(goal.ThumbnailS3Key); + } + + return goal.ThumbnailPresignedUrl; + } + + function videoUrl(goal: Goal) { + if (cloudfrontEnabled()) { + return cloudfrontUrl(goal.S3ObjectKey); + } + + return goal.PresignedUrl; + } + return (
{goal.RedditPostTitle}
-