Persist diff view toggle with localStorage

This commit is contained in:
Chris Wanstrath 2026-03-08 22:21:43 -07:00
parent e0dbc08072
commit 81dcac4097

View File

@ -75,9 +75,12 @@
} }
} }
renderAll("side-by-side"); const saved = localStorage.getItem("sandlot-unified") === "1";
toggle.checked = saved;
renderAll(saved ? "line-by-line" : "side-by-side");
toggle.addEventListener("change", function () { toggle.addEventListener("change", function () {
localStorage.setItem("sandlot-unified", this.checked ? "1" : "0");
renderAll(this.checked ? "line-by-line" : "side-by-side"); renderAll(this.checked ? "line-by-line" : "side-by-side");
}); });
</script> </script>