mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-20 23:33:50 +02:00
fix playerlist icon sorting
This commit is contained in:
@@ -14,12 +14,19 @@ import { i18n } from '../../plugin';
|
|||||||
|
|
||||||
const { t } = i18n.global;
|
const { t } = i18n.global;
|
||||||
|
|
||||||
const sortButton = ({ column, label }) => (
|
const sortButton = ({ column, label, descFirst = false }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="-ml-2 h-8 px-2"
|
class="-ml-2 h-8 px-2"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
onClick={() => {
|
||||||
|
const sorted = column.getIsSorted();
|
||||||
|
if (!sorted && descFirst) {
|
||||||
|
column.toggleSorting(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
column.toggleSorting(sorted === 'asc');
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
<ArrowUpDown class="ml-1 h-4 w-4" />
|
<ArrowUpDown class="ml-1 h-4 w-4" />
|
||||||
@@ -36,9 +43,13 @@ const getInstanceIconWeight = (item) => {
|
|||||||
if (item.isMuted) value -= 50;
|
if (item.isMuted) value -= 50;
|
||||||
if (item.isAvatarInteractionDisabled) value -= 20;
|
if (item.isAvatarInteractionDisabled) value -= 20;
|
||||||
if (item.isChatBoxMuted) value -= 10;
|
if (item.isChatBoxMuted) value -= 10;
|
||||||
|
if (item.ageVerified) value += 5;
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sortInstanceIcon = (a, b) =>
|
||||||
|
getInstanceIconWeight(b) - getInstanceIconWeight(a);
|
||||||
|
|
||||||
export const createColumns = ({
|
export const createColumns = ({
|
||||||
randomUserColours,
|
randomUserColours,
|
||||||
photonLoggingEnabled,
|
photonLoggingEnabled,
|
||||||
@@ -220,16 +231,20 @@ export const createColumns = ({
|
|||||||
{
|
{
|
||||||
id: 'icon',
|
id: 'icon',
|
||||||
header: ({ column }) =>
|
header: ({ column }) =>
|
||||||
sortButton({ column, label: t('table.playerList.icon') }),
|
sortButton({
|
||||||
|
column,
|
||||||
|
label: t('table.playerList.icon'),
|
||||||
|
descFirst: true
|
||||||
|
}),
|
||||||
size: 90,
|
size: 90,
|
||||||
accessorFn: (row) => getInstanceIconWeight(row),
|
accessorFn: (row) => getInstanceIconWeight(row),
|
||||||
meta: {
|
meta: {
|
||||||
class: 'w-[90px] text-center'
|
class: 'w-[90px] text-center'
|
||||||
},
|
},
|
||||||
sortingFn: (rowA, rowB, columnId) => {
|
sortingFn: (rowA, rowB, columnId) => {
|
||||||
const a = rowA.getValue(columnId) ?? 0;
|
const a = rowA.original;
|
||||||
const b = rowB.getValue(columnId) ?? 0;
|
const b = rowB.original;
|
||||||
return b - a;
|
return -sortInstanceIcon(a, b);
|
||||||
},
|
},
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const r = row.original;
|
const r = row.original;
|
||||||
|
|||||||
Reference in New Issue
Block a user