diff --git a/make_post_sell/static/js/watch.js b/make_post_sell/static/js/watch.js index 6612dc0..1e22031 100644 --- a/make_post_sell/static/js/watch.js +++ b/make_post_sell/static/js/watch.js @@ -217,6 +217,16 @@ var initialId = initialProductEl.getAttribute('data-watch-product-id'); currentProductId = initialId; markWatched(initialId); + + // Invalidate stale ring (wrong shop or product removed from ring) + if (ringProductIds.length && ringProductIds.indexOf(initialId) === -1) { + ringProductIds = []; + ringPosition = 0; + ringHistory = {}; + ringLoops = 0; + saveRingState(); + } + syncRingPosition(initialId); if (initialProductEl.getAttribute('data-watch-is-mod') === '1') { isMod = true; @@ -1827,5 +1837,21 @@ rebindToggles(); renderQueue(); - preloadNext(); + + // Seed ring from server if localStorage is empty (first visit, cache cleared) + if (!ringProductIds.length && currentProductId) { + fetchWatchData(currentProductId).then(function(data) { + if (data.ring && data.ring.length) { + ringProductIds = data.ring; + syncRingPosition(currentProductId); + saveRingState(); + updateProgressDisplay(); + } + preloadNext(); + }).catch(function() { + preloadNext(); + }); + } else { + preloadNext(); + } })();