mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
fix datatable sorting issue
This commit is contained in:
@@ -110,26 +110,43 @@
|
|||||||
const detectCreatedAtOrder = (src) => {
|
const detectCreatedAtOrder = (src) => {
|
||||||
if (!Array.isArray(src) || src.length <= 2) return null;
|
if (!Array.isArray(src) || src.length <= 2) return null;
|
||||||
|
|
||||||
let couldBeAsc = true;
|
const detectOrderInRange = (startIndexInclusive, endIndexInclusive) => {
|
||||||
let couldBeDesc = true;
|
let couldBeAsc = true;
|
||||||
const start = Math.max(1, src.length - effectivePageSize.value - 1);
|
let couldBeDesc = true;
|
||||||
for (let i = start; i < src.length; i++) {
|
|
||||||
const a = src[i - 1]?.created_at;
|
const start = Math.max(1, startIndexInclusive);
|
||||||
const b = src[i]?.created_at;
|
const end = Math.min(endIndexInclusive, src.length - 1);
|
||||||
if (typeof a !== 'string' || typeof b !== 'string') continue;
|
for (let i = start; i <= end; i++) {
|
||||||
if (a > b) {
|
const a = src[i - 1]?.created_at;
|
||||||
couldBeAsc = false;
|
const b = src[i]?.created_at;
|
||||||
} else if (a < b) {
|
if (typeof a !== 'string' || typeof b !== 'string') continue;
|
||||||
couldBeDesc = false;
|
if (a > b) {
|
||||||
}
|
couldBeAsc = false;
|
||||||
if (!couldBeAsc && !couldBeDesc) {
|
} else if (a < b) {
|
||||||
return null;
|
couldBeDesc = false;
|
||||||
|
}
|
||||||
|
if (!couldBeAsc && !couldBeDesc) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (couldBeAsc) return 'asc';
|
||||||
|
if (couldBeDesc) return 'desc';
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const windowSize = Math.min(Math.max(effectivePageSize.value + 1, 25), 200);
|
||||||
|
const headEnd = Math.min(src.length - 1, windowSize);
|
||||||
|
const tailStart = Math.max(1, src.length - windowSize);
|
||||||
|
|
||||||
|
const headOrder = detectOrderInRange(1, headEnd);
|
||||||
|
const tailOrder = detectOrderInRange(tailStart, src.length - 1);
|
||||||
|
|
||||||
|
if (headOrder && tailOrder && headOrder !== tailOrder) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (couldBeAsc) return 'asc';
|
return tailOrder || headOrder;
|
||||||
if (couldBeDesc) return 'desc';
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const throttledData = ref(asRawArray(data.value));
|
const throttledData = ref(asRawArray(data.value));
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DataTable v-bind="notificationTable" ref="notificationTableRef" class="notification-table">
|
<DataTable v-bind="notificationTable" ref="notificationTableRef" class="notification-table">
|
||||||
<el-table-column :label="t('table.notification.date')" prop="created_at" :sortable="true" width="130">
|
<el-table-column :label="t('table.notification.date')" prop="created_at" width="130">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip placement="right">
|
<el-tooltip placement="right">
|
||||||
<template #content>
|
<template #content>
|
||||||
|
|||||||
Reference in New Issue
Block a user