fix: refresh the remote session position before transfer
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
The bar polls every 5s; re-read the session at transfer time so a recent seek or progress update is used. Remove the temporary dev test harness.
This commit is contained in:
1 parent
a07ae9b264
commit
289ac4958d
1 file changed
+21
-5
@@ -30,17 +30,33 @@ export const transferSessionToLocal = async (
|
||||
userId: string | undefined,
|
||||
session: SessionInfoDto,
|
||||
): Promise<"audio" | "video" | "none"> => {
|
||||
const item = session.NowPlayingItem;
|
||||
if (!api || !userId || !item?.Id || !session.Id) {
|
||||
if (!api || !userId || !session.Id) {
|
||||
return "none";
|
||||
}
|
||||
|
||||
const positionTicks = session.PlayState?.PositionTicks ?? 0;
|
||||
// The bar/dialog polls sessions every few seconds; refresh the target so a
|
||||
// seek made in the meantime is reflected in the transfer position.
|
||||
let currentSession = session;
|
||||
try {
|
||||
const fresh = (await getSessionApi(api).getSessions()).data.find(
|
||||
(entry) => entry.Id === session.Id,
|
||||
);
|
||||
if (fresh) currentSession = fresh;
|
||||
} catch (error) {
|
||||
console.warn("Could not refresh the remote session", error);
|
||||
}
|
||||
|
||||
const item = currentSession.NowPlayingItem;
|
||||
if (!item?.Id) {
|
||||
return "none";
|
||||
}
|
||||
|
||||
const positionTicks = currentSession.PlayState?.PositionTicks ?? 0;
|
||||
|
||||
// Rebuild the remote queue when the server reports it.
|
||||
let queue: BaseItemDto[] = [item];
|
||||
let queueIndex = 0;
|
||||
const queueIds = (session.NowPlayingQueue ?? [])
|
||||
const queueIds = (currentSession.NowPlayingQueue ?? [])
|
||||
.map((queueItem) => queueItem.Id)
|
||||
.filter((id): id is string => Boolean(id));
|
||||
if (queueIds.length > 0) {
|
||||
@@ -107,7 +123,7 @@ export const transferSessionToLocal = async (
|
||||
// Transfer, not cast: the remote device should stop.
|
||||
try {
|
||||
await getSessionApi(api).sendPlaystateCommand({
|
||||
sessionId: session.Id,
|
||||
sessionId: currentSession.Id,
|
||||
command: "Stop",
|
||||
controllingUserId: userId,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user