mirror of
https://github.com/liyunze-coding/rython-task-bot-v2.git
synced 2026-09-22 07:24:27 +00:00
update colours automatically
This commit is contained in:
parent
ad883d3818
commit
2ded10ce54
4 changed files with 52 additions and 0 deletions
|
|
@ -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({
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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({
|
||||||
|
|
|
||||||
|
|
@ -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({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue