mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
Fix previous instance page index and sort order
This commit is contained in:
@@ -11,7 +11,9 @@
|
|||||||
:table-style="tableStyle"
|
:table-style="tableStyle"
|
||||||
:page-sizes="pageSizes"
|
:page-sizes="pageSizes"
|
||||||
:total-items="totalItems"
|
:total-items="totalItems"
|
||||||
:on-page-size-change="handlePageSizeChange">
|
:on-page-size-change="handlePageSizeChange"
|
||||||
|
:on-page-change="handlePageChange"
|
||||||
|
:on-sort-change="handleSortChange">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||||
<Location :location="location.tag" style="font-size: 14px" />
|
<Location :location="location.tag" style="font-size: 14px" />
|
||||||
@@ -43,15 +45,42 @@
|
|||||||
import { useVrcxVueTable } from '../../../lib/table/useVrcxVueTable';
|
import { useVrcxVueTable } from '../../../lib/table/useVrcxVueTable';
|
||||||
|
|
||||||
const { lookupUser } = useUserStore();
|
const { lookupUser } = useUserStore();
|
||||||
const { previousInstancesInfoDialog } = storeToRefs(useInstanceStore());
|
const { previousInstancesInfoDialog, previousInstancesInfoState } = storeToRefs(useInstanceStore());
|
||||||
const { gameLogIsFriend, gameLogIsFavorite } = useGameLogStore();
|
const { gameLogIsFriend, gameLogIsFavorite } = useGameLogStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const dialogState = computed(() => {
|
||||||
|
return previousInstancesInfoState.value;
|
||||||
|
});
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const rawRows = ref([]);
|
const rawRows = ref([]);
|
||||||
const pageSizes = [10, 25, 50, 100];
|
const pageSizes = [10, 25, 50, 100];
|
||||||
const pageSize = ref(10);
|
const pageSize = computed({
|
||||||
|
get: () => dialogState.value.pageSize,
|
||||||
|
set: (value) => {
|
||||||
|
dialogState.value.pageSize = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const pageIndex = computed({
|
||||||
|
get: () => dialogState.value.pageIndex,
|
||||||
|
set: (value) => {
|
||||||
|
dialogState.value.pageIndex = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
const tableStyle = { maxHeight: '400px' };
|
const tableStyle = { maxHeight: '400px' };
|
||||||
|
const search = computed({
|
||||||
|
get: () => dialogState.value.search,
|
||||||
|
set: (value) => {
|
||||||
|
dialogState.value.search = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const sortBy = computed({
|
||||||
|
get: () => dialogState.value.sortBy,
|
||||||
|
set: (value) => {
|
||||||
|
dialogState.value.sortBy = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const location = ref({
|
const location = ref({
|
||||||
tag: '',
|
tag: '',
|
||||||
@@ -79,7 +108,6 @@
|
|||||||
|
|
||||||
const { stringComparer } = storeToRefs(useSearchStore());
|
const { stringComparer } = storeToRefs(useSearchStore());
|
||||||
const vrcxStore = useVrcxStore();
|
const vrcxStore = useVrcxStore();
|
||||||
const search = ref('');
|
|
||||||
|
|
||||||
const displayRows = computed(() => {
|
const displayRows = computed(() => {
|
||||||
const q = String(search.value ?? '')
|
const q = String(search.value ?? '')
|
||||||
@@ -103,9 +131,9 @@
|
|||||||
},
|
},
|
||||||
columns: columns.value,
|
columns: columns.value,
|
||||||
getRowId: (row) => row?.id ?? row?.userId ?? row?.displayName ?? JSON.stringify(row ?? {}),
|
getRowId: (row) => row?.id ?? row?.userId ?? row?.displayName ?? JSON.stringify(row ?? {}),
|
||||||
initialSorting: [{ id: 'created_at', desc: true }],
|
initialSorting: sortBy.value,
|
||||||
initialPagination: {
|
initialPagination: {
|
||||||
pageIndex: 0,
|
pageIndex: pageIndex.value,
|
||||||
pageSize: pageSize.value
|
pageSize: pageSize.value
|
||||||
},
|
},
|
||||||
tableOptions: {
|
tableOptions: {
|
||||||
@@ -134,6 +162,14 @@
|
|||||||
pageSize.value = size;
|
pageSize.value = size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePageChange = (page) => {
|
||||||
|
pageIndex.value = Math.max(0, page - 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSortChange = (sorting) => {
|
||||||
|
sortBy.value = sorting;
|
||||||
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => previousInstancesInfoDialog.value.visible,
|
() => previousInstancesInfoDialog.value.visible,
|
||||||
(value) => {
|
(value) => {
|
||||||
@@ -150,6 +186,10 @@
|
|||||||
function init() {
|
function init() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
location.value = parseLocation(previousInstancesInfoDialog.value.instanceId);
|
location.value = parseLocation(previousInstancesInfoDialog.value.instanceId);
|
||||||
|
if (previousInstancesInfoDialog.value.lastId !== previousInstancesInfoDialog.value.instanceId) {
|
||||||
|
table.setPageIndex(0);
|
||||||
|
previousInstancesInfoDialog.value.lastId = previousInstancesInfoDialog.value.instanceId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshPreviousInstancesInfoTable() {
|
function refreshPreviousInstancesInfoTable() {
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
:page-sizes="pageSizes"
|
:page-sizes="pageSizes"
|
||||||
:total-items="totalItems"
|
:total-items="totalItems"
|
||||||
:on-page-size-change="handlePageSizeChange"
|
:on-page-size-change="handlePageSizeChange"
|
||||||
:on-page-change="handlePageChange">
|
:on-page-change="handlePageChange"
|
||||||
|
:on-sort-change="handleSortChange">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||||
<span style="font-size: 14px" v-text="headerText"></span>
|
<span style="font-size: 14px" v-text="headerText"></span>
|
||||||
@@ -87,6 +88,7 @@
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
previousInstancesListState.value[props.variant] = {
|
previousInstancesListState.value[props.variant] = {
|
||||||
|
sortBy: [{ id: 'created_at', desc: true }],
|
||||||
search: '',
|
search: '',
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
pageIndex: 0
|
pageIndex: 0
|
||||||
@@ -110,6 +112,12 @@
|
|||||||
getListState().search = value;
|
getListState().search = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const sortBy = computed({
|
||||||
|
get: () => getListState().sortBy,
|
||||||
|
set: (value) => {
|
||||||
|
getListState().sortBy = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const headerText = computed(() => {
|
const headerText = computed(() => {
|
||||||
const state = dialogState.value;
|
const state = dialogState.value;
|
||||||
@@ -118,6 +126,12 @@
|
|||||||
return state?.groupRef?.name ?? '';
|
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(() => {
|
const persistKey = computed(() => {
|
||||||
if (props.variant === 'user') return 'previousInstancesUserDialog';
|
if (props.variant === 'user') return 'previousInstancesUserDialog';
|
||||||
if (props.variant === 'world') return 'previousInstancesWorldDialog';
|
if (props.variant === 'world') return 'previousInstancesWorldDialog';
|
||||||
@@ -201,7 +215,7 @@
|
|||||||
},
|
},
|
||||||
columns: columns.value,
|
columns: columns.value,
|
||||||
getRowId: (row) => `${row?.location ?? ''}:${row?.created_at ?? ''}`,
|
getRowId: (row) => `${row?.location ?? ''}:${row?.created_at ?? ''}`,
|
||||||
initialSorting: [{ id: 'created_at', desc: true }],
|
initialSorting: sortBy.value,
|
||||||
initialPagination: {
|
initialPagination: {
|
||||||
pageIndex: pageIndex.value,
|
pageIndex: pageIndex.value,
|
||||||
pageSize: pageSize.value
|
pageSize: pageSize.value
|
||||||
@@ -236,19 +250,27 @@
|
|||||||
pageIndex.value = Math.max(0, page - 1);
|
pageIndex.value = Math.max(0, page - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSortChange = (sorting) => {
|
||||||
|
sortBy.value = sorting;
|
||||||
|
};
|
||||||
|
|
||||||
const refreshTable = async () => {
|
const refreshTable = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const array = [];
|
const array = [];
|
||||||
try {
|
try {
|
||||||
|
const D = previousInstancesListDialog.value;
|
||||||
|
if (currentId.value !== D.lastId) {
|
||||||
|
table.setPageIndex(0);
|
||||||
|
D.lastId = currentId.value;
|
||||||
|
}
|
||||||
if (props.variant === 'user') {
|
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()) {
|
for (const item of data.values()) {
|
||||||
item.$location = parseLocation(item.location);
|
item.$location = parseLocation(item.location);
|
||||||
item.timer = item.time > 0 ? timeToText(item.time) : '';
|
item.timer = item.time > 0 ? timeToText(item.time) : '';
|
||||||
array.push(item);
|
array.push(item);
|
||||||
}
|
}
|
||||||
} else if (props.variant === 'world') {
|
} else if (props.variant === 'world') {
|
||||||
const D = previousInstancesListDialog.value;
|
|
||||||
const data = await database.getPreviousInstancesByWorldId(D.worldRef);
|
const data = await database.getPreviousInstancesByWorldId(D.worldRef);
|
||||||
for (const ref of data.values()) {
|
for (const ref of data.values()) {
|
||||||
ref.$location = parseLocation(ref.location);
|
ref.$location = parseLocation(ref.location);
|
||||||
@@ -256,7 +278,6 @@
|
|||||||
array.push(ref);
|
array.push(ref);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const D = previousInstancesListDialog.value;
|
|
||||||
const data = await database.getPreviousInstancesByGroupId(D.groupRef.id);
|
const data = await database.getPreviousInstancesByGroupId(D.groupRef.id);
|
||||||
for (const ref of data.values()) {
|
for (const ref of data.values()) {
|
||||||
ref.$location = parseLocation(ref.location);
|
ref.$location = parseLocation(ref.location);
|
||||||
|
|||||||
@@ -176,6 +176,10 @@
|
|||||||
type: Function,
|
type: Function,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
onSortChange: {
|
||||||
|
type: Function,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
onRowClick: {
|
onRowClick: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null
|
default: null
|
||||||
@@ -323,6 +327,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const sortBy = computed(() => props.table.getState?.().sorting ?? []);
|
||||||
|
|
||||||
|
watch(sortBy, (newSorting) => {
|
||||||
|
if (props.onSortChange) {
|
||||||
|
props.onSortChange(newSorting);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
watch([currentPage, pageSizeProxy], async () => {
|
watch([currentPage, pageSizeProxy], async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (tableScrollRef.value) {
|
if (tableScrollRef.value) {
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
|||||||
|
|
||||||
async function lookupAvatarsByAuthor(providerUrl, authorId) {
|
async function lookupAvatarsByAuthor(providerUrl, authorId) {
|
||||||
const avatars = [];
|
const avatars = [];
|
||||||
if (!providerUrl) {
|
if (!providerUrl || !authorId) {
|
||||||
return avatars;
|
return avatars;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
+29
-4
@@ -112,6 +112,7 @@ export const useInstanceStore = defineStore('Instance', () => {
|
|||||||
|
|
||||||
const previousInstancesInfoDialog = ref({
|
const previousInstancesInfoDialog = ref({
|
||||||
instanceId: '',
|
instanceId: '',
|
||||||
|
lastId: '',
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -129,13 +130,36 @@ export const useInstanceStore = defineStore('Instance', () => {
|
|||||||
groupRef: {
|
groupRef: {
|
||||||
id: '',
|
id: '',
|
||||||
name: ''
|
name: ''
|
||||||
}
|
},
|
||||||
|
lastId: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const previousInstancesInfoState = ref({
|
||||||
|
sortBy: [{ id: 'created_at', desc: true }],
|
||||||
|
search: '',
|
||||||
|
pageSize: 10,
|
||||||
|
pageIndex: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const previousInstancesListState = ref({
|
const previousInstancesListState = ref({
|
||||||
user: { search: '', pageSize: 10, pageIndex: 0 },
|
user: {
|
||||||
world: { search: '', pageSize: 10, pageIndex: 0 },
|
sortBy: [{ id: 'created_at', desc: true }],
|
||||||
group: { search: '', pageSize: 10, pageIndex: 0 }
|
search: '',
|
||||||
|
pageSize: 10,
|
||||||
|
pageIndex: 0
|
||||||
|
},
|
||||||
|
world: {
|
||||||
|
sortBy: [{ id: 'created_at', desc: true }],
|
||||||
|
search: '',
|
||||||
|
pageSize: 10,
|
||||||
|
pageIndex: 0
|
||||||
|
},
|
||||||
|
group: {
|
||||||
|
sortBy: [{ id: 'created_at', desc: true }],
|
||||||
|
search: '',
|
||||||
|
pageSize: 10,
|
||||||
|
pageIndex: 0
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const instanceJoinHistory = reactive(new Map());
|
const instanceJoinHistory = reactive(new Map());
|
||||||
@@ -1427,6 +1451,7 @@ export const useInstanceStore = defineStore('Instance', () => {
|
|||||||
currentInstanceLocation,
|
currentInstanceLocation,
|
||||||
queuedInstances,
|
queuedInstances,
|
||||||
previousInstancesInfoDialog,
|
previousInstancesInfoDialog,
|
||||||
|
previousInstancesInfoState,
|
||||||
previousInstancesListDialog,
|
previousInstancesListDialog,
|
||||||
previousInstancesListState,
|
previousInstancesListState,
|
||||||
instanceJoinHistory,
|
instanceJoinHistory,
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
v-if="isFetching"
|
v-if="isFetching"
|
||||||
class="grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] items-center rounded-md bg-transparent p-3 w-70">
|
class="grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] items-center rounded-md bg-transparent p-3 w-70">
|
||||||
<div class="flex justify-between text-sm mb-1">
|
<div class="flex justify-between text-sm mb-1">
|
||||||
<span>{{ t('view.charts.mutual_friend.progress.friends_processed') }}</span>
|
<span class="mr-1">{{ t('view.charts.mutual_friend.progress.friends_processed') }}</span>
|
||||||
<strong>{{ fetchState.processedFriends }} / {{ totalFriends }}</strong>
|
<strong>{{ fetchState.processedFriends }} / {{ totalFriends }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<Progress :model-value="progressPercent" class="h-3" />
|
<Progress :model-value="progressPercent" class="h-3" />
|
||||||
|
|||||||
Reference in New Issue
Block a user