diff --git a/public/js/app.js b/public/js/app.js index beed47db..5cdf78cb 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -495,6 +495,15 @@ document.addEventListener('DOMContentLoaded', function() { // Expose activateTab globally so auth.js can call it after login window.activateTab = activateTab; + // A share link pasted into a tab that is already open changes only the hash, + // so nothing reloads. Treat it like a fresh arrival: note the token, open My + // Resources, and let it ask whether to add the resource. + window.addEventListener('hashchange', function() { + var wanted = null; + try { wanted = openTabFromHash(window, document, window.localStorage); } catch (e) {} + if (wanted && window.CURRENT_USER) activateTab(wanted); + }); + document.querySelectorAll('.tab-btn').forEach(function(btn) { btn.addEventListener('click', function() { activateTab(btn.getAttribute('data-tab'));