Skip to content

Commit dc3a3c3

Browse files
committed
fix packages
1 parent 91b9c87 commit dc3a3c3

5 files changed

Lines changed: 7798 additions & 33 deletions

File tree

frontend/components/TileCard.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ export default function TileCard({ tile, large }: TileCardProps) {
2828
setFetching(true);
2929

3030
fetchSingleTile(tile.id.toString()).then((_tile) => {
31-
setTile(_tile);
31+
if (_tile) {
32+
setTile(_tile);
3233

33-
if (_tile.historical_images && Array.isArray(_tile.historical_images)) {
34-
const unsortedArray = [..._tile.historical_images];
35-
setSortedHistoricalImages(
36-
unsortedArray.sort(function (a, b) {
37-
return b.blockNumber - a.blockNumber;
34+
if (_tile.historical_images && Array.isArray(_tile.historical_images)) {
35+
const unsortedArray = [..._tile.historical_images];
36+
setSortedHistoricalImages(
37+
unsortedArray.sort(function (a, b) {
38+
return b.blockNumber - a.blockNumber;
3839
})
3940
);
4041
}
42+
}
4143
setFetching(false);
4244
});
4345
}

frontend/utils/api.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ export const fetchTiles = async () => {
1313
}
1414
};
1515

16-
export const fetchSingleTile = async (id: string): Promise<PixelMapTile> => {
17-
let tile: PixelMapTile = { id: parseInt(id) };
16+
export const fetchSingleTile = async (id: string): Promise<PixelMapTile | undefined> => {
17+
if (id == undefined) {
18+
return undefined;
19+
}
1820

19-
if (id != undefined) {
20-
try {
21-
const res = await fetch(`https://pixelmap.art/tile/${id}.json`);
22-
const data = await res.json();
23-
tile = { ...tile, ...data };
24-
} catch (err) {
25-
console.error("Error fetching tile data:", err);
26-
}
21+
try {
22+
const res = await fetch(`https://pixelmap.art/tile/${id}.json`);
23+
const data = await res.json();
24+
return { id: parseInt(id), ...data };
25+
} catch (err) {
26+
console.error("Error fetching tile data:", err);
27+
return undefined;
2728
}
28-
29-
return tile;
3029
};
3130

3231
export interface TimeCapsuleTile {

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
"doc": "docs"
88
},
99
"scripts": {
10-
"test": "npm run test:frontend && npm run test:backend",
11-
"test:frontend": "cd frontend && npm test",
10+
"test": "pnpm run test:frontend && pnpm run test:backend",
11+
"test:frontend": "cd frontend && pnpm test",
1212
"test:backend": "cd backend && go test ./...",
13-
"test:coverage": "npm run test:frontend:coverage && npm run test:backend:coverage",
14-
"test:frontend:coverage": "cd frontend && npm run test:coverage",
13+
"test:coverage": "pnpm run test:frontend:coverage && pnpm run test:backend:coverage",
14+
"test:frontend:coverage": "cd frontend && pnpm run test:coverage",
1515
"test:backend:coverage": "cd backend && go test ./... -coverprofile=coverage.out && go tool cover -html=coverage.out -o coverage.html",
16-
"test:coverage:combined": "npm run test:coverage && node ./combine-coverage.js",
17-
"codecov": "npm run test:coverage && node ./combine-coverage.js && curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov && ./codecov"
16+
"test:coverage:combined": "pnpm run test:coverage && node ./combine-coverage.js",
17+
"codecov": "pnpm run test:coverage && node ./combine-coverage.js && curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov && ./codecov"
1818
},
1919
"author": "",
2020
"license": "ISC",

0 commit comments

Comments
 (0)