Merge pull request #6954 from aaronraimist/download-tooltip

pull/21833/head
Germain 2021-10-15 11:57:39 +01:00 committed by GitHub
commit f0ff3a26cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -20,7 +20,7 @@ import React from "react";
import { RovingAccessibleTooltipButton } from "../../../accessibility/RovingTabIndex"; import { RovingAccessibleTooltipButton } from "../../../accessibility/RovingTabIndex";
import Spinner from "../elements/Spinner"; import Spinner from "../elements/Spinner";
import classNames from "classnames"; import classNames from "classnames";
import { _t } from "../../../languageHandler"; import { _t, _td } from "../../../languageHandler";
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import { FileDownloader } from "../../../utils/FileDownloader"; import { FileDownloader } from "../../../utils/FileDownloader";
@ -36,6 +36,7 @@ interface IProps {
interface IState { interface IState {
loading: boolean; loading: boolean;
blob?: Blob; blob?: Blob;
tooltip: string;
} }
@replaceableComponent("views.messages.DownloadActionButton") @replaceableComponent("views.messages.DownloadActionButton")
@ -47,12 +48,17 @@ export default class DownloadActionButton extends React.PureComponent<IProps, IS
this.state = { this.state = {
loading: false, loading: false,
tooltip: _td("Downloading"),
}; };
} }
private onDownloadClick = async () => { private onDownloadClick = async () => {
if (this.state.loading) return; if (this.state.loading) return;
if (this.props.mediaEventHelperGet().media.isEncrypted) {
this.setState({ tooltip: _td("Decrypting") });
}
this.setState({ loading: true }); this.setState({ loading: true });
if (this.state.blob) { if (this.state.blob) {
@ -87,7 +93,7 @@ export default class DownloadActionButton extends React.PureComponent<IProps, IS
return <RovingAccessibleTooltipButton return <RovingAccessibleTooltipButton
className={classes} className={classes}
title={spinner ? _t("Decrypting") : _t("Download")} title={spinner ? _t(this.state.tooltip) : _t("Download")}
onClick={this.onDownloadClick} onClick={this.onDownloadClick}
disabled={!!spinner} disabled={!!spinner}
> >

View File

@ -1959,6 +1959,7 @@
"Saturday": "Saturday", "Saturday": "Saturday",
"Today": "Today", "Today": "Today",
"Yesterday": "Yesterday", "Yesterday": "Yesterday",
"Downloading": "Downloading",
"Decrypting": "Decrypting", "Decrypting": "Decrypting",
"Download": "Download", "Download": "Download",
"View Source": "View Source", "View Source": "View Source",