Appease the linter
This commit is contained in:
parent
455c103890
commit
761fb6e1d5
2 changed files with 10 additions and 11 deletions
|
@ -113,7 +113,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
private iframe: React.RefObject<HTMLIFrameElement> = createRef();
|
private iframe: React.RefObject<HTMLIFrameElement> = createRef();
|
||||||
private dummyLink: React.RefObject<HTMLAnchorElement> = createRef();
|
private dummyLink: React.RefObject<HTMLAnchorElement> = createRef();
|
||||||
private userDidClick = false;
|
private userDidClick = false;
|
||||||
private fileDownloader: FileDownloader = new FileDownloader(() => this.iframe.current)
|
private fileDownloader: FileDownloader = new FileDownloader(() => this.iframe.current);
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -142,7 +142,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
imgSrc: DOWNLOAD_ICON_URL,
|
imgSrc: DOWNLOAD_ICON_URL,
|
||||||
imgStyle: null,
|
imgStyle: null,
|
||||||
style: computedStyle(this.dummyLink.current),
|
style: computedStyle(this.dummyLink.current),
|
||||||
textContent: _t("Download %(text)s", { text })
|
textContent: _t("Download %(text)s", { text }),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,21 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export type getIframeFn = () => HTMLIFrameElement;
|
export type getIframeFn = () => HTMLIFrameElement; // eslint-disable-line @typescript-eslint/naming-convention
|
||||||
|
|
||||||
export const DEFAULT_STYLES = {
|
export const DEFAULT_STYLES = {
|
||||||
imgSrc: "",
|
imgSrc: "",
|
||||||
imgStyle: null, // css props
|
imgStyle: null, // css props
|
||||||
style: "",
|
style: "",
|
||||||
textContent: "",
|
textContent: "",
|
||||||
}
|
};
|
||||||
|
|
||||||
type DownloadOptions = {
|
type DownloadOptions = {
|
||||||
blob: Blob,
|
blob: Blob;
|
||||||
name: string,
|
name: string;
|
||||||
autoDownload?: boolean,
|
autoDownload?: boolean;
|
||||||
opts?: typeof DEFAULT_STYLES
|
opts?: typeof DEFAULT_STYLES;
|
||||||
}
|
};
|
||||||
|
|
||||||
// set up the iframe as a singleton so we don't have to figure out destruction of it down the line.
|
// set up the iframe as a singleton so we don't have to figure out destruction of it down the line.
|
||||||
let managedIframe: HTMLIFrameElement;
|
let managedIframe: HTMLIFrameElement;
|
||||||
|
@ -90,9 +90,8 @@ export class FileDownloader {
|
||||||
return iframe;
|
return iframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async download({blob, name, autoDownload = true, opts = DEFAULT_STYLES}: DownloadOptions) {
|
public async download({ blob, name, autoDownload = true, opts = DEFAULT_STYLES }: DownloadOptions) {
|
||||||
const iframe = this.iframe; // get the iframe first just in case we need to await onload
|
const iframe = this.iframe; // get the iframe first just in case we need to await onload
|
||||||
console.log("@@", {blob, name, autoDownload, opts, iframe, m: iframe === managedIframe, p: this.onLoadPromise});
|
|
||||||
if (this.onLoadPromise) await this.onLoadPromise;
|
if (this.onLoadPromise) await this.onLoadPromise;
|
||||||
iframe.contentWindow.postMessage({
|
iframe.contentWindow.postMessage({
|
||||||
...opts,
|
...opts,
|
||||||
|
|
Loading…
Reference in a new issue