more download fixes

This commit is contained in:
subnub
2025-02-21 13:55:00 -05:00
parent bcf0b5003f
commit 56ba2b3f6c
2 changed files with 18 additions and 6 deletions
+12 -6
View File
@@ -2,6 +2,7 @@ import { QueryFunctionContext } from "react-query";
import axios from "../axiosInterceptor";
import { getUserToken } from "./userAPI";
import getBackendURL from "../utils/getBackendURL";
import { isPwa } from "../utils/PWAUtils";
interface QueryKeyParams {
parent: string;
@@ -71,12 +72,17 @@ export const downloadFileAPI = async (fileID: string) => {
const url = `${getBackendURL()}/file-service/download/${fileID}`;
const link = document.createElement("a");
document.body.appendChild(link);
link.href = url;
link.setAttribute("type", "hidden");
link.setAttribute("download", "true");
link.click();
if (!isPwa()) {
const link = document.createElement("a");
document.body.appendChild(link);
link.href = url;
link.setAttribute("type", "hidden");
link.setAttribute("download", "true");
link.click();
} else {
alert("PWA");
window.open(url);
}
};
export const getVideoTokenAPI = async () => {
+6
View File
@@ -0,0 +1,6 @@
export const isPwa = () => {
return ["fullscreen", "standalone", "minimal-ui"].some(
(displayMode) =>
window.matchMedia("(display-mode: " + displayMode + ")").matches
);
};