@torrent-tv/proxy 2.101.12 → 2.101.13
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.
package/package.json
CHANGED
|
@@ -31,8 +31,9 @@ export async function handleApiSourcesPost(req, reply, { sourceRegistry, viewers
|
|
|
31
31
|
return reply.code(400).send({ error: "sourceType and source are required." });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const sourceKey = await sourceRegistry.upsert(sourceType, source);
|
|
35
34
|
const consumerId = typeof payload.consumerId === "string" ? payload.consumerId.trim() : "";
|
|
36
|
-
|
|
35
|
+
const viewer = consumerId ? viewers?.present(consumerId) : null;
|
|
36
|
+
const sourceKey = await sourceRegistry.upsert(sourceType, source);
|
|
37
|
+
if (viewer && viewers.get(consumerId) === viewer) viewers.selectsSource(consumerId, sourceKey);
|
|
37
38
|
return reply.send({ sourceKey, playbackMapVersion: 1 });
|
|
38
39
|
}
|
|
@@ -97,7 +97,9 @@ export class Viewers {
|
|
|
97
97
|
if (!Array.isArray(indices) || indices.some(index => !Number.isSafeInteger(index) || index < 0)) {
|
|
98
98
|
throw new TypeError("Visible files need source indices.");
|
|
99
99
|
}
|
|
100
|
-
const viewer = this.
|
|
100
|
+
const viewer = this.get(consumerId);
|
|
101
|
+
if (!viewer?.isPresent() || viewer.source?.sourceKey !== sourceKey) return null;
|
|
102
|
+
viewer.seen(now);
|
|
101
103
|
const visible = [...new Set(indices)];
|
|
102
104
|
if (JSON.stringify(viewer.source.visibleFileIndices) !== JSON.stringify(visible)) {
|
|
103
105
|
viewer.source.visibleFileIndices = visible;
|