X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Fpages%2FAlttpSeed.js;fp=resources%2Fjs%2Fcomponents%2Fpages%2FAlttpSeed.js;h=0000000000000000000000000000000000000000;hb=16662be0b3432d67307ae8c2bb798362d77bab99;hp=005d19a95830ab802ae15cbb130b391127c1993e;hpb=d8ca13d8ccb5efe181198d0e5243a26c9f807aa1;p=alttp.git
diff --git a/resources/js/components/pages/AlttpSeed.js b/resources/js/components/pages/AlttpSeed.js
deleted file mode 100644
index 005d19a..0000000
--- a/resources/js/components/pages/AlttpSeed.js
+++ /dev/null
@@ -1,108 +0,0 @@
-import axios from 'axios';
-import React, { useCallback, useEffect, useState } from 'react';
-import { Helmet } from 'react-helmet';
-import { useParams } from 'react-router-dom';
-
-import NotFound from './NotFound';
-import Seed from '../alttp-seeds/Seed';
-import ErrorBoundary from '../common/ErrorBoundary';
-import ErrorMessage from '../common/ErrorMessage';
-import Loading from '../common/Loading';
-
-const AlttpSeed = () => {
- const params = useParams();
- const { hash } = params;
-
- const [error, setError] = useState(null);
- const [loading, setLoading] = useState(true);
- const [patch, setPatch] = useState(null);
- const [seed, setSeed] = useState(null);
-
- const loadSeed = useCallback((hash, ctrl) => {
- axios
- .get(`/api/alttp-seed/${hash}`, { signal: ctrl.signal })
- .then(response => {
- setError(null);
- setLoading(false);
- setSeed(response.data);
- })
- .catch(error => {
- setError(error);
- setLoading(false);
- setSeed(null);
- });
- }, []);
-
- useEffect(() => {
- setLoading(true);
- const ctrl = new AbortController();
- loadSeed(hash, ctrl);
- return () => {
- ctrl.abort();
- };
- }, [hash]);
-
- useEffect(() => {
- if (!seed || seed.status !== 'pending') {
- return;
- }
- const ctrl = new AbortController();
- const timer = setTimeout(() => {
- loadSeed(seed.hash, ctrl);
- }, 2000);
- return () => {
- clearTimeout(timer);
- ctrl.abort();
- };
- }, [seed]);
-
- useEffect(() => {
- setPatch(null);
- if (!seed || seed.status !== 'generated') {
- return;
- }
- const ctrl = new AbortController();
- axios
- .get(`/alttp-seeds/${hash}.bps`, {
- responseType: 'arraybuffer',
- signal: ctrl.signal,
- })
- .then(response => {
- setPatch(response.data);
- })
- .catch(error => {
- setError(error);
- });
- return () => {
- ctrl.abort();
- };
- }, [hash, seed]);
-
- const retry = useCallback(async () => {
- await axios.post(`/api/alttp-seed/${hash}/retry`);
- setSeed(seed => ({ ...seed, status: 'pending' }));
- });
-
- if (loading) {
- return ;
- }
-
- if (error) {
- return ;
- }
-
- if (!seed) {
- return ;
- }
-
- return
-
- {seed ?
- {seed.hash}
- : null}
-
-
- ;
-};
-
-export default AlttpSeed;