From ec77debbd650432a091f620bceadebacd6f6891d Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 4 Jun 2025 16:37:06 -0700 Subject: [PATCH] Use regular links for downloading --- .../src/components/DownloadLink.js | 60 ------------------- .../src/components/Metadata.js | 5 +- 2 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 packages/skin-museum-client/src/components/DownloadLink.js diff --git a/packages/skin-museum-client/src/components/DownloadLink.js b/packages/skin-museum-client/src/components/DownloadLink.js deleted file mode 100644 index 1b6f4481..00000000 --- a/packages/skin-museum-client/src/components/DownloadLink.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from "react"; -import { Subject } from "rxjs"; -import { switchMap, distinctUntilChanged, map } from "rxjs/operators"; -import Disposable from "../Disposable"; - -// The `download` attribute on `` tags is not respected on cross origin -// assets. However, it does work for Object URLs. So, we download the skin as -// soon as we show the link and swap out the href with the Object URL as soon as -// it's loaded. The skin should already be cahced, so it should not actually -// result in an extra network request. -// -// There may be a breif time where the download link will use the hash name instead -// of the real name, but it's probably too short to actually ever be hit by a real user. -export default class DownloadLink extends React.Component { - constructor(props) { - super(props); - this.state = { href: null }; - this._hrefs = new Subject(); - this._disposables = new Disposable(); - } - - componentDidMount() { - this._disposables.add( - this._hrefs - .pipe( - distinctUntilChanged(), - switchMap((href) => fetch(href)), - switchMap((response) => response.blob()), - map((blob) => URL.createObjectURL(blob)) - ) - .subscribe((url) => { - this.setState({ href: url }); - }) - ); - this._hrefs.next(this.props.href); - } - - componentDidUpdate(_prevProps, prevState) { - if (prevState.href !== this.state.href) { - URL.revokeObjectURL(prevState.href); - } - this._hrefs.next(this.props.href); - } - - componentWillUnmount() { - if (this.state.href) { - URL.revokeObjectURL(this.state.href); - } - this._disposables.dispose(); - } - - render() { - return ( - - {/* We have to explicitly set the children to make ESLint happy */} - {this.props.children} - - ); - } -} diff --git a/packages/skin-museum-client/src/components/Metadata.js b/packages/skin-museum-client/src/components/Metadata.js index e8517c9f..63fcd0cb 100644 --- a/packages/skin-museum-client/src/components/Metadata.js +++ b/packages/skin-museum-client/src/components/Metadata.js @@ -1,5 +1,4 @@ import React, { useEffect, useState } from "react"; -import DownloadLink from "./DownloadLink"; import * as Utils from "../utils"; import LinkInput from "./LinkInput"; // import { API_URL } from "../constants"; @@ -59,13 +58,13 @@ function Metadata() { } const elements = [ - Download - , + , readmeLink, /*