mirror of
https://github.com/usememos/memos.git
synced 2025-11-13 02:41:23 +08:00
chore: use for...of
This commit is contained in:
parent
f6af564d4e
commit
1424036ccd
1 changed files with 9 additions and 14 deletions
|
|
@ -120,22 +120,17 @@ const MemoActionMenu = (props: Props) => {
|
||||||
const confirmed = window.confirm(t("memo.remove-completed-task-list-items-confirm"));
|
const confirmed = window.confirm(t("memo.remove-completed-task-list-items-confirm"));
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
const newNodes = JSON.parse(JSON.stringify(memo.nodes));
|
const newNodes = JSON.parse(JSON.stringify(memo.nodes));
|
||||||
for (let i = 0; i < newNodes.length; i++) {
|
for (const node of newNodes) {
|
||||||
if (newNodes[i].type === NodeType.LIST && newNodes[i].listNode?.children?.length > 0) {
|
if (node.type === NodeType.LIST && node.listNode?.children?.length > 0) {
|
||||||
let childrenLength = newNodes[i].listNode.children.length;
|
const children = node.listNode.children;
|
||||||
for (let j = 0; j < childrenLength; j++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
if (
|
if (children[i].type === NodeType.TASK_LIST_ITEM && children[i].taskListItemNode?.complete) {
|
||||||
newNodes[i].listNode.children[j].type === NodeType.TASK_LIST_ITEM &&
|
|
||||||
newNodes[i].listNode.children[j].taskListItemNode?.complete
|
|
||||||
) {
|
|
||||||
// Remove completed taskList item and next line breaks
|
// Remove completed taskList item and next line breaks
|
||||||
newNodes[i].listNode.children.splice(j, 1);
|
children.splice(i, 1);
|
||||||
if (newNodes[i].listNode.children[j]?.type === NodeType.LINE_BREAK) {
|
if (children[i]?.type === NodeType.LINE_BREAK) {
|
||||||
newNodes[i].listNode.children.splice(j, 1);
|
children.splice(i, 1);
|
||||||
childrenLength--;
|
|
||||||
}
|
}
|
||||||
childrenLength--;
|
i--;
|
||||||
j--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue