mirror of
https://github.com/Qortal/q-share.git
synced 2025-02-01 07:42:22 +00:00
fix when download gets stuck
This commit is contained in:
parent
5888fd7fff
commit
a4dca30d11
@ -75,6 +75,8 @@ export default function FileElement({
|
|||||||
const [fileProperties, setFileProperties] = React.useState<any>(null);
|
const [fileProperties, setFileProperties] = React.useState<any>(null);
|
||||||
const [downloadLoader, setDownloadLoader] = React.useState<any>(false);
|
const [downloadLoader, setDownloadLoader] = React.useState<any>(false);
|
||||||
const downloads = useSelector((state: RootState) => state.global?.downloads);
|
const downloads = useSelector((state: RootState) => state.global?.downloads);
|
||||||
|
const status = React.useRef<null | string>(null)
|
||||||
|
|
||||||
const hasCommencedDownload = React.useRef(false);
|
const hasCommencedDownload = React.useRef(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const reDownload = React.useRef<boolean>(false)
|
const reDownload = React.useRef<boolean>(false)
|
||||||
@ -200,10 +202,10 @@ export default function FileElement({
|
|||||||
const refetchInInterval = ()=> {
|
const refetchInInterval = ()=> {
|
||||||
try {
|
try {
|
||||||
const interval = setInterval(()=> {
|
const interval = setInterval(()=> {
|
||||||
if(resourceStatus?.current === 'DOWNLOADED'){
|
if(status?.current === 'DOWNLOADED'){
|
||||||
refetch()
|
refetch()
|
||||||
}
|
}
|
||||||
if(resourceStatus?.current === 'READY'){
|
if(status?.current === 'READY'){
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +215,20 @@ export default function FileElement({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if(resourceStatus?.status){
|
||||||
|
status.current = resourceStatus?.status
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
resourceStatus?.status === 'DOWNLOADED' &&
|
||||||
|
reDownload?.current === false
|
||||||
|
) {
|
||||||
|
refetchInInterval()
|
||||||
|
reDownload.current = true
|
||||||
|
}
|
||||||
|
}, [resourceStatus])
|
||||||
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (
|
if (
|
||||||
resourceStatus?.status === "READY" &&
|
resourceStatus?.status === "READY" &&
|
||||||
@ -227,12 +243,6 @@ export default function FileElement({
|
|||||||
alertType: "info",
|
alertType: "info",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else if (
|
|
||||||
resourceStatus?.status === 'DOWNLOADED' &&
|
|
||||||
reDownload?.current === false
|
|
||||||
) {
|
|
||||||
refetchInInterval()
|
|
||||||
reDownload.current = true
|
|
||||||
}
|
}
|
||||||
}, [resourceStatus, download]);
|
}, [resourceStatus, download]);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useRef } from "react";
|
import React, { useState, useRef } from "react";
|
||||||
import { Box, Button, Input, Popover, useTheme } from "@mui/material";
|
import { Box, Button, Input, Popover, Typography, useTheme } from "@mui/material";
|
||||||
import ExitToAppIcon from "@mui/icons-material/ExitToApp";
|
import ExitToAppIcon from "@mui/icons-material/ExitToApp";
|
||||||
import { BlockedNamesModal } from "../../common/BlockedNamesModal/BlockedNamesModal";
|
import { BlockedNamesModal } from "../../common/BlockedNamesModal/BlockedNamesModal";
|
||||||
import AddBoxIcon from "@mui/icons-material/AddBox";
|
import AddBoxIcon from "@mui/icons-material/AddBox";
|
||||||
@ -100,6 +100,12 @@ const NavBar: React.FC<Props> = ({
|
|||||||
return (
|
return (
|
||||||
<CustomAppBar position="sticky" elevation={2}>
|
<CustomAppBar position="sticky" elevation={2}>
|
||||||
<ThemeSelectRow>
|
<ThemeSelectRow>
|
||||||
|
<Box sx={{
|
||||||
|
display: 'flex',
|
||||||
|
height: '100%',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '20px'
|
||||||
|
}}>
|
||||||
<LogoContainer
|
<LogoContainer
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
@ -120,6 +126,11 @@ const NavBar: React.FC<Props> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</LogoContainer>
|
</LogoContainer>
|
||||||
|
<Typography sx={{
|
||||||
|
fontSize: '16px',
|
||||||
|
whiteSpace: 'nowrap'
|
||||||
|
}}>Sharing is caring</Typography>
|
||||||
|
</Box>
|
||||||
</ThemeSelectRow>
|
</ThemeSelectRow>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
@ -178,7 +178,7 @@ export const useFetchVideos = () => {
|
|||||||
if(reset){
|
if(reset){
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
const videoLimit = limit || 20
|
const videoLimit = limit || 50
|
||||||
let defaultUrl = `/arbitrary/resources/search?mode=ALL&includemetadata=false&reverse=true&excludeblocked=true&exactmatchnames=true&offset=${offset}&limit=${videoLimit}`;
|
let defaultUrl = `/arbitrary/resources/search?mode=ALL&includemetadata=false&reverse=true&excludeblocked=true&exactmatchnames=true&offset=${offset}&limit=${videoLimit}`;
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
|
@ -56,7 +56,7 @@ export const VideoListComponentLevel = ({ mode }: VideoListProps) => {
|
|||||||
const getVideos = React.useCallback(async () => {
|
const getVideos = React.useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const offset = videos.length
|
const offset = videos.length
|
||||||
const url = `/arbitrary/resources/search?mode=ALL&service=DOCUMENT&query=${QTUBE_VIDEO_BASE}_&limit=20&includemetadata=false&reverse=true&excludeblocked=true&name=${paramName}&exactmatchnames=true&offset=${offset}`
|
const url = `/arbitrary/resources/search?mode=ALL&service=DOCUMENT&query=${QTUBE_VIDEO_BASE}_&limit=50&includemetadata=false&reverse=true&excludeblocked=true&name=${paramName}&exactmatchnames=true&offset=${offset}`
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
Reference in New Issue
Block a user