Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

preload hero #7

Merged
merged 1 commit into from
Nov 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preload" as="image" href="/assets/images/hero.jpg">
<title>CyberTicket</title>
</head>
<body>
Expand Down
16 changes: 2 additions & 14 deletions src/client/foundation/pages/Top/Top.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,8 @@ function useTodayRacesWithAnimation(races) {
* @param {Model.Race[]} todayRaces
* @returns {string | null}
*/
function useHeroImage(todayRaces) {
const firstRaceId = todayRaces[0]?.id;
const url =
firstRaceId !== undefined
? `/api/hero?firstRaceId=${firstRaceId}`
: "/api/hero";
const { data } = useFetch(url, jsonFetcher);

if (firstRaceId === undefined || data === null) {
return null;
}

const imageUrl = `${data.url}?${data.hash}`;
return imageUrl;
function useHeroImage(_todayRaces) {
return "/assets/images/hero.jpg";
}

/** @type {React.VFC} */
Expand Down
8 changes: 0 additions & 8 deletions src/server/routes/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import moment from "moment-timezone";
import { Between, LessThanOrEqual, MoreThanOrEqual } from "typeorm";

import { assets } from "../../client/foundation/utils/UrlUtils.js";
import { BettingTicket, Race, User } from "../../model/index.js";
import { createConnection } from "../typeorm/connection.js";
import { initialize } from "../typeorm/initialize.js";
Expand Down Expand Up @@ -39,13 +38,6 @@ export const apiRoute = async (fastify) => {
res.status(204).send();
});

fastify.get("/hero", async (_req, res) => {
const url = assets("/images/hero.jpg");
const hash = Math.random().toFixed(10).substring(2);

res.send({ hash, url });
});

fastify.get("/races", async (req, res) => {
const since =
req.query.since != null ? moment.unix(req.query.since) : undefined;
Expand Down