Skip to content

Fix watched video sync when using browser back button#11

Open
rm335 wants to merge 1 commit intobierteam:masterfrom
rm335:fix/sync-viewed-videos-on-back-navigation
Open

Fix watched video sync when using browser back button#11
rm335 wants to merge 1 commit intobierteam:masterfrom
rm335:fix/sync-viewed-videos-on-back-navigation

Conversation

@rm335
Copy link
Copy Markdown

@rm335 rm335 commented Mar 24, 2026

Summary

  • Fix watched videos not syncing when navigating back in Dumpert's new UI
  • Add pagehide, pageshow, popstate, and visibilitychange event listeners to cover bfcache and SPA navigation scenarios where beforeunload does not fire

Problem

The extension relied on beforeunload and click events to sync viewed items between sessionStorage and localStorage. Modern browsers use the back-forward cache (bfcache), which suppresses beforeunload. Additionally, Dumpert's new SPA UI uses the History API for navigation, triggering popstate instead of a page unload. This meant watched video state was lost when using the back button.

Solution

Added four additional event listeners:

Event Covers
pagehide Page entering bfcache (replacement for beforeunload)
pageshow Page restored from bfcache via back button
popstate SPA back/forward navigation (History API)
visibilitychange Tab losing focus (tab switch, minimize)

Test plan

  • Open Dumpert, watch a video, press browser back button — video should remain marked as watched
  • Navigate between pages using in-site links — viewed state should persist
  • Close and reopen the tab — previously watched videos should still be marked
  • Switch tabs and return — viewed state should be synced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant