From 5e68d3809c61b5b33bf6e4363775f3dc6214ad9f Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Thu, 5 Feb 2026 19:15:09 -0800 Subject: [PATCH] [WV2] Fix syncing for play/pause state across page morphs Reproduce: 1. Add an item with animations, and play them. 2. Remove the item. 3. Add it back. 4. Observe the button shows up in "Paused" state, even though it's playing. This is because the server-side template wasn't doing anything to try to keep the play/pause button it renders in sync with the current saved state in the cookies, so it was always causing a morph to the pause state. Now we listen to the cookie instead! I also updated the JS behavior to be a bit more consistent: treat the behavior as defaulting to true, unless it's explicitly set to the string "false". --- app/assets/javascripts/outfit-viewer.js | 2 +- app/views/wardrobe/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/outfit-viewer.js b/app/assets/javascripts/outfit-viewer.js index 243bff5c..20bf3fcb 100644 --- a/app/assets/javascripts/outfit-viewer.js +++ b/app/assets/javascripts/outfit-viewer.js @@ -145,7 +145,7 @@ class OutfitViewer extends HTMLElement { .split("; ") .find((row) => row.startsWith("DTIOutfitViewerIsPlaying=")); if (cookie) { - return cookie.split("=")[1] === "true"; + return cookie.split("=")[1] !== "false"; } return true; // Default to playing } diff --git a/app/views/wardrobe/show.html.haml b/app/views/wardrobe/show.html.haml index f639570b..a7913e89 100644 --- a/app/views/wardrobe/show.html.haml +++ b/app/views/wardrobe/show.html.haml @@ -35,7 +35,7 @@ .preview-controls-top %outfit-viewer-play-pause-toggle{for: "wardrobe-outfit-viewer"} %label.play-pause-control-button.button - %input{type: "checkbox"} + %input{type: "checkbox", checked: cookies[:DTIOutfitViewerIsPlaying] != "false"} %span.paused-label Paused %span.playing-label Playing