Skip to content

Commit 0a70881

Browse files
committed
♻️ Refactoring (#1619)
1 parent 432409c commit 0a70881

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/routes/workbooks/edit/[slug]/+page.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@
4141
4242
// HACK: $effect だと workBookTasksForTable が更新されない
4343
run(() => {
44-
workBookTasksForTable = $form.workBookTasks.map((workBookTask) => {
45-
const task = tasksMapByIds.get(workBookTask.taskId);
44+
workBookTasksForTable = $form.workBookTasks
45+
.map((workBookTask) => {
46+
const task = tasksMapByIds.get(workBookTask.taskId);
47+
48+
if (!task) {
49+
return null;
50+
}
4651
47-
if (task) {
4852
return {
4953
contestId: task.contest_id,
5054
title: task.title,
5155
taskId: workBookTask.taskId,
5256
priority: workBookTask.priority,
5357
comment: workBookTask.comment,
5458
};
55-
}
56-
}) as WorkBookTasksEdit;
59+
})
60+
.filter((item): item is NonNullable<typeof item> => item !== null);
5761
});
5862
</script>
5963

0 commit comments

Comments
 (0)