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

Commit

Permalink
Merge pull request #7 from euglena1215/euglena1215/preload-hero
Browse files Browse the repository at this point in the history
preload hero
  • Loading branch information
euglena1215 authored Nov 27, 2022
2 parents 9f55c49 + 1031352 commit 68c2199
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
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

0 comments on commit 68c2199

Please sign in to comment.