mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-24 17:23:50 +02:00
Fix previous instance page index and sort order
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
:page-sizes="pageSizes"
|
||||
:total-items="totalItems"
|
||||
:on-page-size-change="handlePageSizeChange"
|
||||
:on-page-change="handlePageChange">
|
||||
:on-page-change="handlePageChange"
|
||||
:on-sort-change="handleSortChange">
|
||||
<template #toolbar>
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<span style="font-size: 14px" v-text="headerText"></span>
|
||||
@@ -87,6 +88,7 @@
|
||||
return state;
|
||||
}
|
||||
previousInstancesListState.value[props.variant] = {
|
||||
sortBy: [{ id: 'created_at', desc: true }],
|
||||
search: '',
|
||||
pageSize: 10,
|
||||
pageIndex: 0
|
||||
@@ -110,6 +112,12 @@
|
||||
getListState().search = value;
|
||||
}
|
||||
});
|
||||
const sortBy = computed({
|
||||
get: () => getListState().sortBy,
|
||||
set: (value) => {
|
||||
getListState().sortBy = value;
|
||||
}
|
||||
});
|
||||
|
||||
const headerText = computed(() => {
|
||||
const state = dialogState.value;
|
||||
@@ -118,6 +126,12 @@
|
||||
return state?.groupRef?.name ?? '';
|
||||
});
|
||||
|
||||
const currentId = computed(() => {
|
||||
if (props.variant === 'user') return dialogState.value?.userRef?.id ?? '';
|
||||
if (props.variant === 'world') return dialogState.value?.worldRef?.id ?? '';
|
||||
return dialogState.value?.groupRef?.id ?? '';
|
||||
});
|
||||
|
||||
const persistKey = computed(() => {
|
||||
if (props.variant === 'user') return 'previousInstancesUserDialog';
|
||||
if (props.variant === 'world') return 'previousInstancesWorldDialog';
|
||||
@@ -201,7 +215,7 @@
|
||||
},
|
||||
columns: columns.value,
|
||||
getRowId: (row) => `${row?.location ?? ''}:${row?.created_at ?? ''}`,
|
||||
initialSorting: [{ id: 'created_at', desc: true }],
|
||||
initialSorting: sortBy.value,
|
||||
initialPagination: {
|
||||
pageIndex: pageIndex.value,
|
||||
pageSize: pageSize.value
|
||||
@@ -236,19 +250,27 @@
|
||||
pageIndex.value = Math.max(0, page - 1);
|
||||
};
|
||||
|
||||
const handleSortChange = (sorting) => {
|
||||
sortBy.value = sorting;
|
||||
};
|
||||
|
||||
const refreshTable = async () => {
|
||||
loading.value = true;
|
||||
const array = [];
|
||||
try {
|
||||
const D = previousInstancesListDialog.value;
|
||||
if (currentId.value !== D.lastId) {
|
||||
table.setPageIndex(0);
|
||||
D.lastId = currentId.value;
|
||||
}
|
||||
if (props.variant === 'user') {
|
||||
const data = await database.getPreviousInstancesByUserId(previousInstancesListDialog.value.userRef);
|
||||
const data = await database.getPreviousInstancesByUserId(D.userRef);
|
||||
for (const item of data.values()) {
|
||||
item.$location = parseLocation(item.location);
|
||||
item.timer = item.time > 0 ? timeToText(item.time) : '';
|
||||
array.push(item);
|
||||
}
|
||||
} else if (props.variant === 'world') {
|
||||
const D = previousInstancesListDialog.value;
|
||||
const data = await database.getPreviousInstancesByWorldId(D.worldRef);
|
||||
for (const ref of data.values()) {
|
||||
ref.$location = parseLocation(ref.location);
|
||||
@@ -256,7 +278,6 @@
|
||||
array.push(ref);
|
||||
}
|
||||
} else {
|
||||
const D = previousInstancesListDialog.value;
|
||||
const data = await database.getPreviousInstancesByGroupId(D.groupRef.id);
|
||||
for (const ref of data.values()) {
|
||||
ref.$location = parseLocation(ref.location);
|
||||
|
||||
Reference in New Issue
Block a user