From a676b0ee6178ad45370864195afa09c87d865265 Mon Sep 17 00:00:00 2001
From: dakkar <dakkar@thenautilus.net>
Date: Sun, 7 Apr 2024 17:50:53 +0100
Subject: [PATCH] paginate in offset mode when querying emoji - fixes #490

since the backend sorts emojis by name length when a query is present,
the normal pagination with `sinceId` / `untilId` would not work
reliably

`offsetMode` is better in this case, although it will produce
non-stable results if custom emojis that match the query are added or
removed while we paginate
---
 packages/frontend/src/pages/custom-emojis-manager.vue | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/packages/frontend/src/pages/custom-emojis-manager.vue b/packages/frontend/src/pages/custom-emojis-manager.vue
index 1f9a99d4f5..9357735c82 100644
--- a/packages/frontend/src/pages/custom-emojis-manager.vue
+++ b/packages/frontend/src/pages/custom-emojis-manager.vue
@@ -98,6 +98,9 @@ const selectedEmojis = ref<string[]>([]);
 const pagination = {
 	endpoint: 'admin/emoji/list' as const,
 	limit: 30,
+	offsetMode: computed(() => (
+		(query.value && query.value !== '') ? true : false
+	)),
 	params: computed(() => ({
 		query: (query.value && query.value !== '') ? query.value : null,
 	})),