Skip to content

Commit

Permalink
feat: TodoList.getTopologySortedList에서 filter 조건 받아 사용하도록 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
n-ryu committed Dec 6, 2022
1 parent 890dab8 commit 5450be9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions client/src/core/todo/todoList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ export class TodoList {
return this.todoList.find((el) => el.id === id)?.toPlain();
}

async getTopologySortedList(): Promise<Map<string, DiagramTodo>> {
async getTopologySortedList(filter: (todo: Todo) => boolean): Promise<Map<string, DiagramTodo>> {
const cloneTodoList = new Map<string, Todo>(
(await this.getSortedListWithFilter(() => true, [])).map((el) => [el.id, new Todo(el)]),
(await this.getSortedListWithFilter(filter, [])).map((el) => [el.id, new Todo(el)]),
);
const resultTodoList = new Map<string, DiagramTodo>(
(await this.getSortedListWithFilter(() => true, [])).map((el) => [el.id, { depth: NaN, todo: new Todo(el) }]),
(await this.getSortedListWithFilter(filter, [])).map((el) => [el.id, { depth: NaN, todo: new Todo(el) }]),
);

const updateDepth = (id: string, depth: number): void => {
Expand All @@ -255,7 +255,9 @@ export class TodoList {
};

const forwardQueue = new Queue(
this.todoList.filter((el) => this.checkPrev(el) && el.state !== 'DONE').map((el) => ({ depth: 0, id: el.id })),
this.todoList
.filter((el) => filter(el) && this.checkPrev(el) && el.state !== 'DONE')
.map((el) => ({ depth: 0, id: el.id })),
);
while (!forwardQueue.isEmpty()) {
const target = forwardQueue.pop();
Expand Down

0 comments on commit 5450be9

Please sign in to comment.