update colours automatically

This commit is contained in:
liyunze 2026-08-12 16:11:59 +10:00
parent ad883d3818
commit 2ded10ce54
4 changed files with 52 additions and 0 deletions

View file

@ -95,6 +95,23 @@ class TaskList {
return this; return this;
} }
updateUserColor(sectionId, color) {
const section = this.#data.find((s) => s.id === sectionId);
if (!section) return this;
section.color = color;
document
.querySelectorAll(".section")
.forEach((el) => {
if (el.dataset.key !== sectionId) return;
const title = el.querySelector(":scope > .section-title");
if (!title) return;
title.style.setProperty("--user-color", color);
title.classList.add("has-user-color");
});
return this;
}
addTask(sectionId, task, sectionTitle) { addTask(sectionId, task, sectionTitle) {
if (!this.#data.find((s) => s.id === sectionId)) { if (!this.#data.find((s) => s.id === sectionId)) {
this.addSection({ this.addSection({

View file

@ -46,6 +46,7 @@ async function onChatMessage(data) {
localStorage.setItem(`${key}-color`, userColor); localStorage.setItem(`${key}-color`, userColor);
userColors[`${key}-color`] = userColor; userColors[`${key}-color`] = userColor;
taskList?.updateUserColor(key, userColor);
} }
} }

View file

@ -72,6 +72,23 @@ class TaskList {
return this; return this;
} }
updateUserColor(sectionId, color) {
const section = this.#data.find((s) => s.id === sectionId);
if (!section) return this;
section.color = color;
document
.querySelectorAll(".section")
.forEach((el) => {
if (el.dataset.key !== sectionId) return;
const title = el.querySelector(":scope > .section-title");
if (!title) return;
title.style.setProperty("--user-color", color);
title.classList.add("has-user-color");
});
return this;
}
addTask(sectionId, task, sectionTitle) { addTask(sectionId, task, sectionTitle) {
if (!this.#data.find((s) => s.id === sectionId)) { if (!this.#data.find((s) => s.id === sectionId)) {
this.addSection({ this.addSection({

View file

@ -95,6 +95,23 @@ class TaskList {
return this; return this;
} }
updateUserColor(sectionId, color) {
const section = this.#data.find((s) => s.id === sectionId);
if (!section) return this;
section.color = color;
document
.querySelectorAll(".section")
.forEach((el) => {
if (el.dataset.key !== sectionId) return;
const title = el.querySelector(":scope > .section-title");
if (!title) return;
title.style.setProperty("--user-color", color);
title.classList.add("has-user-color");
});
return this;
}
addTask(sectionId, task, sectionTitle) { addTask(sectionId, task, sectionTitle) {
if (!this.#data.find((s) => s.id === sectionId)) { if (!this.#data.find((s) => s.id === sectionId)) {
this.addSection({ this.addSection({