From 5b8c6cc93e0c125f8920fce9781aa32e37326607 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 15 May 2022 15:20:01 +0200 Subject: [PATCH] Refactor emoji-edit-dialog to use Composition API (#8657) * refactor(client): refactor emoji-edit-dialog to use Composition API * fix(client): fix editing emoji not updating emoji list * Apply review suggestions from @Johann150 Co-authored-by: Johann150 * fix(client): use cached category info instead of making a request * fix(client): use updateItem in emoji pagination when editing * fix(client): reimplement removeItem in MkPagination * Apply review suggestion from @Johann150 Co-authored-by: Johann150 Co-authored-by: Johann150 --- .../client/src/components/ui/pagination.vue | 6 + .../src/pages/admin/emoji-edit-dialog.vue | 120 ++++++++---------- packages/client/src/pages/admin/emojis.vue | 8 +- 3 files changed, 63 insertions(+), 71 deletions(-) diff --git a/packages/client/src/components/ui/pagination.vue b/packages/client/src/components/ui/pagination.vue index ac6f59c33..9dd18785b 100644 --- a/packages/client/src/components/ui/pagination.vue +++ b/packages/client/src/components/ui/pagination.vue @@ -244,6 +244,11 @@ const append = (item: Item): void => { items.value.push(item); }; +const removeItem = (finder: (item: Item) => boolean) => { + const i = items.value.findIndex(finder); + items.value.splice(i, 1); +}; + const updateItem = (id: Item['id'], replacer: (old: Item) => Item): void => { const i = items.value.findIndex(item => item.id === id); items.value[i] = replacer(items.value[i]); @@ -276,6 +281,7 @@ defineExpose({ fetchMoreAhead, prepend, append, + removeItem, updateItem, }); diff --git a/packages/client/src/pages/admin/emoji-edit-dialog.vue b/packages/client/src/pages/admin/emoji-edit-dialog.vue index 2e3903426..d482fa49e 100644 --- a/packages/client/src/pages/admin/emoji-edit-dialog.vue +++ b/packages/client/src/pages/admin/emoji-edit-dialog.vue @@ -27,85 +27,71 @@ -