Skip to content

Commit

Permalink
特定のパターンのカテゴリ名でピッカーに出てこないのを修正
Browse files Browse the repository at this point in the history
「i18n.ts.other」や「/」始まりの場合壊れる
  • Loading branch information
meronmks committed Oct 28, 2023
1 parent 2e05560 commit d0f9626
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkEmojiPicker.section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:customEmojiTree="child.children"
@chosen="nestedChosen"
>
{{ child.value }}
{{ child.value || i18n.ts.other }}
</MkEmojiPickerSection>
</div>
</section>
Expand Down
23 changes: 9 additions & 14 deletions packages/frontend/src/components/MkEmojiPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ SPDX-License-Identifier: AGPL-3.0-only
v-for="child in customEmojiFolderRoot.children"
:key="`custom:${child.value}`"
:initialShown="false"
:emojis="computed(() => customEmojis.filter(e => child.value === i18n.ts.other ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
:categoryFolderFlag="child.children.length!==0"
:customEmojiTree="child.children"
@chosen="chosen"
>
{{ child.value }}
{{ child.value || i18n.ts.other }}
</XSection>
</div>
<div v-once class="group">
Expand Down Expand Up @@ -156,31 +156,26 @@ const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
const parts = input.split('/');
let category = "";
let currentNode: CustomEmojiFolderTree = root;
const parts = input.split('/');
let currentNode: CustomEmojiFolderTree = root;
for (let part of parts) {
if (part) {
category += `/${part}`;
} else {
part = i18n.ts.other
category += `/`;
if (!part) {
part = '';
}
category = category.replace(/^\//, '');
let existingNode = currentNode.children.find((node) => node.value === part);
if (!existingNode) {
const newNode: CustomEmojiFolderTree = { value: part, category, children: [] };
const newNode: CustomEmojiFolderTree = { value: part, category: input, children: [] };
currentNode.children.push(newNode);
existingNode = newNode;
}
currentNode = existingNode;
}
return currentNode;
return currentNode;
}
customEmojiCategories.value.forEach(ec => {
Expand All @@ -189,7 +184,7 @@ customEmojiCategories.value.forEach(ec => {
}
});
parseAndMergeCategories(i18n.ts.other, customEmojiFolderRoot);
parseAndMergeCategories('', customEmojiFolderRoot);
watch(q, () => {
if (emojisEl.value) emojisEl.value.scrollTop = 0;
Expand Down

0 comments on commit d0f9626

Please sign in to comment.