mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Update the downloader module
This commit is contained in:
parent
3ae167bd16
commit
ae518cafe5
@ -18,7 +18,7 @@
|
|||||||
"@formatjs/intl-displaynames": "^6.6.6",
|
"@formatjs/intl-displaynames": "^6.6.6",
|
||||||
"@formatjs/intl-locale": "^3.4.5",
|
"@formatjs/intl-locale": "^3.4.5",
|
||||||
"@gorhom/portal": "^1.0.14",
|
"@gorhom/portal": "^1.0.14",
|
||||||
"@kesha-antonov/react-native-background-downloader": "^2.10.0",
|
"@kesha-antonov/react-native-background-downloader": "^3.0.1",
|
||||||
"@kyoo/ui": "workspace:^",
|
"@kyoo/ui": "workspace:^",
|
||||||
"@material-symbols/svg-400": "^0.14.6",
|
"@material-symbols/svg-400": "^0.14.6",
|
||||||
"@react-native-community/netinfo": "11.1.0",
|
"@react-native-community/netinfo": "11.1.0",
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
"yoshiki": "*"
|
"yoshiki": "*"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@kesha-antonov/react-native-background-downloader": "^2.10.0",
|
"@kesha-antonov/react-native-background-downloader": "^3.0.1",
|
||||||
"expo-file-system": "^16.0.5",
|
"expo-file-system": "^16.0.5",
|
||||||
"expo-router": "^3.4.6"
|
"expo-router": "^3.4.6"
|
||||||
},
|
},
|
||||||
|
@ -88,9 +88,9 @@ const setupDownloadTask = (
|
|||||||
if (!stateAtom) stateAtom = atom({} as State);
|
if (!stateAtom) stateAtom = atom({} as State);
|
||||||
store.set(stateAtom, {
|
store.set(stateAtom, {
|
||||||
status: task.state,
|
status: task.state,
|
||||||
progress: task.percent * 100,
|
progress: (task.bytesDownloaded / task.bytesTotal) * 100,
|
||||||
size: task.totalBytes,
|
size: task.bytesTotal,
|
||||||
availableSize: task.bytesWritten,
|
availableSize: task.bytesDownloaded,
|
||||||
pause: () => {
|
pause: () => {
|
||||||
task.pause();
|
task.pause();
|
||||||
store.set(stateAtom!, (x) => ({ ...x, state: "PAUSED" }));
|
store.set(stateAtom!, (x) => ({ ...x, state: "PAUSED" }));
|
||||||
@ -126,22 +126,20 @@ const setupDownloadTask = (
|
|||||||
|
|
||||||
task
|
task
|
||||||
.begin(({ expectedBytes }) => update((x) => ({ ...x, size: expectedBytes })))
|
.begin(({ expectedBytes }) => update((x) => ({ ...x, size: expectedBytes })))
|
||||||
.progress((percent, availableSize, size) => {
|
.progress(({ bytesDownloaded, bytesTotal }) => {
|
||||||
update((x) => ({
|
update((x) => ({
|
||||||
...x,
|
...x,
|
||||||
progress: Math.round(percent * 100),
|
progress: Math.round((bytesDownloaded / bytesTotal) * 100),
|
||||||
size,
|
size: bytesTotal,
|
||||||
availableSize,
|
availableSize: bytesDownloaded,
|
||||||
status: "DOWNLOADING",
|
status: "DOWNLOADING",
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
.done(() => {
|
.done(() => {
|
||||||
update((x) => ({ ...x, progress: 100, status: "DONE", play: playFn(state, queryClient) }));
|
update((x) => ({ ...x, progress: 100, status: "DONE", play: playFn(state, queryClient) }));
|
||||||
// apparently this is needed for ios /shrug i'm totaly gona forget this
|
RNBackgroundDownloader.completeHandler(task.id);
|
||||||
// if i ever implement ios so keeping this here
|
|
||||||
if (Platform.OS === "ios") RNBackgroundDownloader.completeHandler(task.id);
|
|
||||||
})
|
})
|
||||||
.error((error) => {
|
.error(({ error }) => {
|
||||||
update((x) => ({ ...x, status: "FAILED", error }));
|
update((x) => ({ ...x, status: "FAILED", error }));
|
||||||
console.error(`Error downloading ${state.data.slug}`, error);
|
console.error(`Error downloading ${state.data.slug}`, error);
|
||||||
ToastAndroid.show(`Error downloading ${state.data.slug}`, ToastAndroid.LONG);
|
ToastAndroid.show(`Error downloading ${state.data.slug}`, ToastAndroid.LONG);
|
||||||
|
@ -2509,12 +2509,12 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@kesha-antonov/react-native-background-downloader@npm:^2.10.0":
|
"@kesha-antonov/react-native-background-downloader@npm:^3.0.1":
|
||||||
version: 2.10.0
|
version: 3.0.1
|
||||||
resolution: "@kesha-antonov/react-native-background-downloader@npm:2.10.0"
|
resolution: "@kesha-antonov/react-native-background-downloader@npm:3.0.1"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react-native: ">=0.57.0"
|
react-native: ">=0.57.0"
|
||||||
checksum: f56e4bf5f28b07d8b9e776ce3bdc6ed715ef3d9a95d3ec67b4852dc2992c51283550b5406106454557654a1c2503e920ec62d895aa6240aae97ba4f029df8a32
|
checksum: f369689009b74add987e667746bd80409646ad2ebb51f9a4831242b365e898975d89759b7effd4169156d74ff4cc89d84318f1ab5a854dcd72bcba91081ba3a0
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -2603,7 +2603,7 @@ __metadata:
|
|||||||
resolution: "@kyoo/ui@workspace:packages/ui"
|
resolution: "@kyoo/ui@workspace:packages/ui"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@gorhom/portal": ^1.0.14
|
"@gorhom/portal": ^1.0.14
|
||||||
"@kesha-antonov/react-native-background-downloader": ^2.10.0
|
"@kesha-antonov/react-native-background-downloader": ^3.0.1
|
||||||
"@kyoo/models": "workspace:^"
|
"@kyoo/models": "workspace:^"
|
||||||
"@kyoo/primitives": "workspace:^"
|
"@kyoo/primitives": "workspace:^"
|
||||||
"@shopify/flash-list": ^1.6.3
|
"@shopify/flash-list": ^1.6.3
|
||||||
@ -10409,7 +10409,7 @@ __metadata:
|
|||||||
"@formatjs/intl-displaynames": ^6.6.6
|
"@formatjs/intl-displaynames": ^6.6.6
|
||||||
"@formatjs/intl-locale": ^3.4.5
|
"@formatjs/intl-locale": ^3.4.5
|
||||||
"@gorhom/portal": ^1.0.14
|
"@gorhom/portal": ^1.0.14
|
||||||
"@kesha-antonov/react-native-background-downloader": ^2.10.0
|
"@kesha-antonov/react-native-background-downloader": ^3.0.1
|
||||||
"@kyoo/ui": "workspace:^"
|
"@kyoo/ui": "workspace:^"
|
||||||
"@material-symbols/svg-400": ^0.14.6
|
"@material-symbols/svg-400": ^0.14.6
|
||||||
"@react-native-community/netinfo": 11.1.0
|
"@react-native-community/netinfo": 11.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user