Skip to content

Commit

Permalink
Merge pull request #134 from scombz-utilities/feature/badge-update
Browse files Browse the repository at this point in the history
バッジの色を変更 / popup開くたびに色を再設定
  • Loading branch information
yudai1204 authored Jan 7, 2025
2 parents b53c155 + dd12a2b commit 55d0b42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/backgrounds/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ export const updateBadgeText = () => {
const filteredTaskList = mergedTaskList
.filter((task) => Date.parse(task.deadline) >= now)
.filter((task) => !currentData.settings.hiddenTaskIdList.includes(task.id))
.filter((task) => !currentData.settings.popupHideFutureTasks || (Date.parse(task.deadline) - now) / 86400000 < currentData.settings.popupHideFutureTasksRange);
.filter(
(task) =>
!currentData.settings.popupHideFutureTasks ||
(Date.parse(task.deadline) - now) / 86400000 < currentData.settings.popupHideFutureTasksRange,
);

filteredTaskList.sort((a, b) => Date.parse(a.deadline) - Date.parse(b.deadline));

if (filteredTaskList.length > 0) {
const rd = (Date.parse(filteredTaskList[0].deadline) - now) / 60000;
if (rd < 60 * 24) {
setBadgeBackgroundColor("#ee3333");
} else if (rd < 60 * 24 * 2) {
setBadgeBackgroundColor("#ff8800");
} else {
setBadgeBackgroundColor("#1a73e8");
}
Expand Down
3 changes: 3 additions & 0 deletions src/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const IndexPopup = () => {
setCourses(timetable);

setLoaded(true);

// タスクのバッジ更新
chrome.runtime.sendMessage({ action: "updateBadgeText" });
});
};

Expand Down

0 comments on commit 55d0b42

Please sign in to comment.