fix: don't open new tab to download attachment (#614)

This commit is contained in:
Jan 2022-05-08 22:53:07 +02:00 committed by GitHub
parent 4f48e3d176
commit 7345172271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import {
Download,
} from "@styled-icons/boxicons-regular";
import { File, Video } from "@styled-icons/boxicons-solid";
import { isFirefox } from "react-device-detect";
import { API } from "revolt.js";
import styles from "./AttachmentActions.module.scss";
@ -51,7 +52,7 @@ export default function AttachmentActions({ attachment }: Props) {
href={download_url}
className={styles.downloadIcon}
download
target="_blank"
target={isFirefox ? "_blank" : "_self"}
rel="noreferrer">
<IconButton>
<Download size={24} />
@ -69,7 +70,7 @@ export default function AttachmentActions({ attachment }: Props) {
href={download_url}
className={styles.downloadIcon}
download
target="_blank"
target={isFirefox ? "_blank" : "_self"}
rel="noreferrer">
<IconButton>
<Download size={24} />
@ -89,7 +90,7 @@ export default function AttachmentActions({ attachment }: Props) {
href={download_url}
className={styles.downloadIcon}
download
target="_blank"
target={isFirefox ? "_blank" : "_self"}
rel="noreferrer">
<IconButton>
<Download size={24} />
@ -118,7 +119,7 @@ export default function AttachmentActions({ attachment }: Props) {
href={download_url}
className={styles.downloadIcon}
download
target="_blank"
target={isFirefox ? "_blank" : "_self"}
rel="noreferrer">
<IconButton>
<Download size={24} />

View file

@ -11,6 +11,7 @@ import {
Trash,
} from "@styled-icons/boxicons-regular";
import { Cog, UserVoice } from "@styled-icons/boxicons-solid";
import { isFirefox } from "react-device-detect";
import { useHistory } from "react-router-dom";
import { Channel, Message, Server, User, API } from "revolt.js";
import { Permission, UserPermission } from "revolt.js";
@ -286,7 +287,7 @@ export default function ContextMenus() {
"attachments",
"attachments/download",
),
"_blank",
isFirefox ? "_blank" : "_self",
);
}
break;