特定のパターンのカテゴリ名でピッカーに出てこないのを修正
「i18n.ts.other」や「/」始まりの場合壊れる
This commit is contained in:
parent
2e05560358
commit
d0f9626849
|
|
@ -52,7 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:customEmojiTree="child.children"
|
:customEmojiTree="child.children"
|
||||||
@chosen="nestedChosen"
|
@chosen="nestedChosen"
|
||||||
>
|
>
|
||||||
{{ child.value }}
|
{{ child.value || i18n.ts.other }}
|
||||||
</MkEmojiPickerSection>
|
</MkEmojiPickerSection>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
v-for="child in customEmojiFolderRoot.children"
|
v-for="child in customEmojiFolderRoot.children"
|
||||||
:key="`custom:${child.value}`"
|
:key="`custom:${child.value}`"
|
||||||
:initialShown="false"
|
: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"
|
:categoryFolderFlag="child.children.length!==0"
|
||||||
:customEmojiTree="child.children"
|
:customEmojiTree="child.children"
|
||||||
@chosen="chosen"
|
@chosen="chosen"
|
||||||
>
|
>
|
||||||
{{ child.value }}
|
{{ child.value || i18n.ts.other }}
|
||||||
</XSection>
|
</XSection>
|
||||||
</div>
|
</div>
|
||||||
<div v-once class="group">
|
<div v-once class="group">
|
||||||
|
|
@ -156,23 +156,18 @@ const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
||||||
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
|
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
|
||||||
|
|
||||||
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
||||||
const parts = input.split('/');
|
const parts = input.split('/');
|
||||||
let category = "";
|
let currentNode: CustomEmojiFolderTree = root;
|
||||||
let currentNode: CustomEmojiFolderTree = root;
|
|
||||||
|
|
||||||
for (let part of parts) {
|
for (let part of parts) {
|
||||||
if (part) {
|
if (!part) {
|
||||||
category += `/${part}`;
|
part = '';
|
||||||
} else {
|
|
||||||
part = i18n.ts.other
|
|
||||||
category += `/`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
category = category.replace(/^\//, '');
|
|
||||||
let existingNode = currentNode.children.find((node) => node.value === part);
|
let existingNode = currentNode.children.find((node) => node.value === part);
|
||||||
|
|
||||||
if (!existingNode) {
|
if (!existingNode) {
|
||||||
const newNode: CustomEmojiFolderTree = { value: part, category, children: [] };
|
const newNode: CustomEmojiFolderTree = { value: part, category: input, children: [] };
|
||||||
currentNode.children.push(newNode);
|
currentNode.children.push(newNode);
|
||||||
existingNode = newNode;
|
existingNode = newNode;
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +175,7 @@ function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): Cu
|
||||||
currentNode = existingNode;
|
currentNode = existingNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentNode;
|
return currentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
customEmojiCategories.value.forEach(ec => {
|
customEmojiCategories.value.forEach(ec => {
|
||||||
|
|
@ -189,7 +184,7 @@ customEmojiCategories.value.forEach(ec => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
parseAndMergeCategories(i18n.ts.other, customEmojiFolderRoot);
|
parseAndMergeCategories('', customEmojiFolderRoot);
|
||||||
|
|
||||||
watch(q, () => {
|
watch(q, () => {
|
||||||
if (emojisEl.value) emojisEl.value.scrollTop = 0;
|
if (emojisEl.value) emojisEl.value.scrollTop = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue