fix(front): reset page to lower or page 1 if we didn't found results in instances view

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2024-01-04 15:47:57 +01:00
parent 2b5439b1d0
commit 48f57ec1cf
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -269,6 +269,20 @@ watch([filterDomain, followStatus], () => {
const instances = computed(() => instancesResult.value?.instances); 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" }); const { t } = useI18n({ useScope: "global" });
useHead({ useHead({
title: computed(() => t("Federation")), title: computed(() => t("Federation")),