react-native-nitro-player 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,17 +43,24 @@ export function useDownloadProgress(options = {}) {
|
|
|
43
43
|
const unsubscribe = downloadCallbackManager.subscribeToProgress((progress) => {
|
|
44
44
|
if (!isMounted.current)
|
|
45
45
|
return;
|
|
46
|
+
const isTerminal = progress.state === 'completed' || progress.state === 'cancelled';
|
|
47
|
+
if (isTerminal) {
|
|
48
|
+
// Always clean up terminal downloads from the map regardless of activeOnly,
|
|
49
|
+
// otherwise completed downloads are never removed when activeOnly=true
|
|
50
|
+
setProgressMap((prev) => {
|
|
51
|
+
if (!prev.has(progress.trackId))
|
|
52
|
+
return prev;
|
|
53
|
+
const next = new Map(prev);
|
|
54
|
+
next.delete(progress.trackId);
|
|
55
|
+
return next;
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
46
59
|
if (!shouldTrack(progress))
|
|
47
60
|
return;
|
|
48
61
|
setProgressMap((prev) => {
|
|
49
62
|
const next = new Map(prev);
|
|
50
|
-
|
|
51
|
-
progress.state === 'cancelled') {
|
|
52
|
-
next.delete(progress.trackId);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
next.set(progress.trackId, progress);
|
|
56
|
-
}
|
|
63
|
+
next.set(progress.trackId, progress);
|
|
57
64
|
return next;
|
|
58
65
|
});
|
|
59
66
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-player",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "A powerful audio player library for React Native with playlist management, playback controls, and support for Android Auto and CarPlay",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -81,18 +81,27 @@ export function useDownloadProgress(
|
|
|
81
81
|
const unsubscribe = downloadCallbackManager.subscribeToProgress(
|
|
82
82
|
(progress) => {
|
|
83
83
|
if (!isMounted.current) return
|
|
84
|
+
|
|
85
|
+
const isTerminal =
|
|
86
|
+
progress.state === 'completed' || progress.state === 'cancelled'
|
|
87
|
+
|
|
88
|
+
if (isTerminal) {
|
|
89
|
+
// Always clean up terminal downloads from the map regardless of activeOnly,
|
|
90
|
+
// otherwise completed downloads are never removed when activeOnly=true
|
|
91
|
+
setProgressMap((prev) => {
|
|
92
|
+
if (!prev.has(progress.trackId)) return prev
|
|
93
|
+
const next = new Map(prev)
|
|
94
|
+
next.delete(progress.trackId)
|
|
95
|
+
return next
|
|
96
|
+
})
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
84
100
|
if (!shouldTrack(progress)) return
|
|
85
101
|
|
|
86
102
|
setProgressMap((prev) => {
|
|
87
103
|
const next = new Map(prev)
|
|
88
|
-
|
|
89
|
-
progress.state === 'completed' ||
|
|
90
|
-
progress.state === 'cancelled'
|
|
91
|
-
) {
|
|
92
|
-
next.delete(progress.trackId)
|
|
93
|
-
} else {
|
|
94
|
-
next.set(progress.trackId, progress)
|
|
95
|
-
}
|
|
104
|
+
next.set(progress.trackId, progress)
|
|
96
105
|
return next
|
|
97
106
|
})
|
|
98
107
|
}
|