カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応

This commit is contained in:
meronmks 2023-10-28 18:00:28 +09:00
parent 0ae2d136e5
commit 2e05560358
No known key found for this signature in database
1 changed files with 17 additions and 13 deletions

View File

@ -160,21 +160,25 @@ function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): Cu
let category = ""; let category = "";
let currentNode: CustomEmojiFolderTree = root; let currentNode: CustomEmojiFolderTree = root;
for (const part of parts) { for (let part of parts) {
if (part) { if (part) {
category += `/${part}`; category += `/${part}`;
category = category.replace(/^\//, ''); } else {
let existingNode = currentNode.children.find((node) => node.value === part); part = i18n.ts.other
category += `/`;
}
if (!existingNode) { category = category.replace(/^\//, '');
const newNode: CustomEmojiFolderTree = { value: part, category, children: [] }; let existingNode = currentNode.children.find((node) => node.value === part);
currentNode.children.push(newNode);
existingNode = newNode;
}
currentNode = existingNode; if (!existingNode) {
} const newNode: CustomEmojiFolderTree = { value: part, category, children: [] };
} currentNode.children.push(newNode);
existingNode = newNode;
}
currentNode = existingNode;
}
return currentNode; return currentNode;
} }