From 48f57ec1cf3ce81c3c83333bea59c2a7d8c70e99 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 4 Jan 2024 15:47:57 +0100 Subject: [PATCH] fix(front): reset page to lower or page 1 if we didn't found results in instances view Signed-off-by: Thomas Citharel --- src/views/Admin/InstancesView.vue | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/views/Admin/InstancesView.vue b/src/views/Admin/InstancesView.vue index 4ef83e150..df2a74b30 100644 --- a/src/views/Admin/InstancesView.vue +++ b/src/views/Admin/InstancesView.vue @@ -269,6 +269,20 @@ watch([filterDomain, followStatus], () => { const instances = computed(() => instancesResult.value?.instances); +const instancesTotal = computed(() => instancesResult.value?.instances.total); +const currentPageInstancesNumber = computed( + () => instancesResult.value?.instances.elements.length +); + +// If we didn't found any instances on this page +watch(instancesTotal, (newInstancesTotal) => { + if (newInstancesTotal === 0) { + instancePage.value = 1; + } else if (currentPageInstancesNumber.value === 0) { + instancePage.value = instancePage.value - 1; + } +}); + const { t } = useI18n({ useScope: "global" }); useHead({ title: computed(() => t("Federation")),