fix: mark per-subreddit mode dirty on color picker change

Without this, new subreddit entries would not persist their color
overrides because _dirtyModes was never set when picking via the
custom color picker.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 17:17:16 -04:00
parent 2abb71fbb8
commit 1b4b5706de

View File

@@ -33,7 +33,7 @@
el.style.backgroundColor = val; el.style.backgroundColor = val;
} }
function openPickerForSwatch(swatchEl) { function openPickerForSwatch(swatchEl, onBeforeChange) {
if (!picker) { if (!picker) {
picker = window.RedditTweaks.colorPicker.create(); picker = window.RedditTweaks.colorPicker.create();
} }
@@ -50,6 +50,7 @@
picker.open(getColorValue(swatchEl), function (hex) { picker.open(getColorValue(swatchEl), function (hex) {
setColorValue(swatchEl, hex); setColorValue(swatchEl, hex);
if (onBeforeChange) onBeforeChange();
saveFromControls(); saveFromControls();
}); });
} }
@@ -161,7 +162,9 @@
[bgSwatch, borderSwatch, textSwatch].forEach(function (swatch) { [bgSwatch, borderSwatch, textSwatch].forEach(function (swatch) {
swatch.addEventListener("click", function () { swatch.addEventListener("click", function () {
openPickerForSwatch(swatch); openPickerForSwatch(swatch, function () {
entry._dirtyModes[modeSelect.value] = true;
});
}); });
}); });