From 84758b6eec2efdccebe847e3ad01f538cc58b46b Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Sun, 4 Feb 2024 13:44:58 +0900 Subject: [PATCH] support update and delete --- .../src/components/grid/MkDataCell.vue | 13 +- .../frontend/src/components/grid/MkGrid.vue | 42 ++--- packages/frontend/src/components/grid/grid.ts | 1 + .../pages/admin/custom-emojis-grid.impl.ts | 7 +- .../pages/admin/custom-emojis-grid.list.vue | 153 ++++++++++++++++-- .../admin/custom-emojis-grid.register.vue | 11 +- 6 files changed, 173 insertions(+), 54 deletions(-) diff --git a/packages/frontend/src/components/grid/MkDataCell.vue b/packages/frontend/src/components/grid/MkDataCell.vue index 40fa2b4812..6c0d087b42 100644 --- a/packages/frontend/src/components/grid/MkDataCell.vue +++ b/packages/frontend/src/components/grid/MkDataCell.vue @@ -50,23 +50,12 @@ diff --git a/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue b/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue index 9eb75ac45b..5c2fda4f35 100644 --- a/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue +++ b/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue @@ -154,17 +154,20 @@ async function onRegistryClicked() { const items = new Map(gridItems.value.map(it => [`${it.fileId}|${it.name}`, it])); const upload = async (): Promise => { + const emptyStrToNull = (value: string) => value === '' ? null : value; + const emptyStrToEmptyArray = (value: string) => value === '' ? [] : value.split(',').map(it => it.trim()); + const result = Array.of(); for (const [key, item] of [...items.entries()].slice(0, MAXIMUM_EMOJI_COUNT)) { try { await misskeyApi('admin/emoji/add', { name: item.name, - category: item.category, - aliases: item.aliases.split(',').map(it => it.trim()), - license: item.license, + category: emptyStrToNull(item.category), + aliases: emptyStrToEmptyArray(item.aliases), + license: emptyStrToNull(item.license), isSensitive: item.isSensitive, localOnly: item.localOnly, - roleIdsThatCanBeUsedThisEmojiAsReaction: item.roleIdsThatCanBeUsedThisEmojiAsReaction.split(',').map(it => it.trim()), + roleIdsThatCanBeUsedThisEmojiAsReaction: emptyStrToEmptyArray(item.roleIdsThatCanBeUsedThisEmojiAsReaction), fileId: item.fileId!, }); result.push({ key, item, success: true, err: undefined });