mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
refactor friends sort
This commit is contained in:
@@ -138,6 +138,29 @@
|
||||
params: {}
|
||||
});
|
||||
|
||||
const friendSections = computed(() => [
|
||||
{
|
||||
key: 'friendsInInstance',
|
||||
label: t('dialog.invite.friends_in_instance'),
|
||||
friends: props.inviteDialog?.friendsInInstance ?? []
|
||||
},
|
||||
{
|
||||
key: 'vip',
|
||||
label: t('side_panel.favorite'),
|
||||
friends: vipFriends.value
|
||||
},
|
||||
{
|
||||
key: 'online',
|
||||
label: t('side_panel.online'),
|
||||
friends: onlineFriends.value
|
||||
},
|
||||
{
|
||||
key: 'active',
|
||||
label: t('side_panel.active'),
|
||||
friends: activeFriends.value
|
||||
}
|
||||
]);
|
||||
|
||||
const userPickerGroups = computed(() => {
|
||||
const groups = [];
|
||||
|
||||
@@ -156,7 +179,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
const addFriendGroup = (key, label, friends) => {
|
||||
const addFriendGroup = ({ key, label, friends }) => {
|
||||
if (!friends?.length) return;
|
||||
groups.push({
|
||||
key,
|
||||
@@ -174,10 +197,7 @@
|
||||
});
|
||||
};
|
||||
|
||||
addFriendGroup('friendsInInstance', t('dialog.invite.friends_in_instance'), props.inviteDialog?.friendsInInstance);
|
||||
addFriendGroup('vip', t('side_panel.favorite'), vipFriends.value);
|
||||
addFriendGroup('online', t('side_panel.online'), onlineFriends.value);
|
||||
addFriendGroup('active', t('side_panel.active'), activeFriends.value);
|
||||
friendSections.value.forEach(addFriendGroup);
|
||||
|
||||
return groups;
|
||||
});
|
||||
@@ -194,10 +214,11 @@
|
||||
|
||||
const friendById = computed(() => {
|
||||
const map = new Map();
|
||||
for (const friend of props.inviteDialog?.friendsInInstance ?? []) map.set(friend.id, friend);
|
||||
for (const friend of vipFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of onlineFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of activeFriends.value) map.set(friend.id, friend);
|
||||
for (const section of friendSections.value) {
|
||||
for (const friend of section.friends ?? []) {
|
||||
map.set(friend.id, friend);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
|
||||
@@ -142,12 +142,36 @@
|
||||
}
|
||||
]);
|
||||
|
||||
const friendSections = computed(() => [
|
||||
{
|
||||
key: 'vip',
|
||||
label: t('side_panel.favorite'),
|
||||
friends: vipFriends.value
|
||||
},
|
||||
{
|
||||
key: 'online',
|
||||
label: t('side_panel.online'),
|
||||
friends: onlineFriends.value
|
||||
},
|
||||
{
|
||||
key: 'active',
|
||||
label: t('side_panel.active'),
|
||||
friends: activeFriends.value
|
||||
},
|
||||
{
|
||||
key: 'offline',
|
||||
label: t('side_panel.offline'),
|
||||
friends: offlineFriends.value
|
||||
}
|
||||
]);
|
||||
|
||||
const friendById = computed(() => {
|
||||
const map = new Map();
|
||||
for (const friend of vipFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of onlineFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of activeFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of offlineFriends.value) map.set(friend.id, friend);
|
||||
for (const section of friendSections.value) {
|
||||
for (const friend of section.friends ?? []) {
|
||||
map.set(friend.id, friend);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
@@ -190,7 +214,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
const addFriendGroup = (key, label, friends) => {
|
||||
const addFriendGroup = ({ key, label, friends }) => {
|
||||
if (!friends?.length) return;
|
||||
groups.push({
|
||||
key,
|
||||
@@ -208,10 +232,7 @@
|
||||
});
|
||||
};
|
||||
|
||||
addFriendGroup('vip', t('side_panel.favorite'), vipFriends.value);
|
||||
addFriendGroup('online', t('side_panel.online'), onlineFriends.value);
|
||||
addFriendGroup('active', t('side_panel.active'), activeFriends.value);
|
||||
addFriendGroup('offline', t('side_panel.offline'), offlineFriends.value);
|
||||
friendSections.value.forEach(addFriendGroup);
|
||||
|
||||
return groups;
|
||||
});
|
||||
|
||||
@@ -675,12 +675,36 @@
|
||||
return names.slice(0, 3).join(', ') + (names.length > 3 ? ` +${names.length - 3}` : '');
|
||||
});
|
||||
|
||||
const friendSections = computed(() => [
|
||||
{
|
||||
key: 'vip',
|
||||
label: t('side_panel.favorite'),
|
||||
friends: vipFriends.value
|
||||
},
|
||||
{
|
||||
key: 'online',
|
||||
label: t('side_panel.online'),
|
||||
friends: onlineFriends.value
|
||||
},
|
||||
{
|
||||
key: 'active',
|
||||
label: t('side_panel.active'),
|
||||
friends: activeFriends.value
|
||||
},
|
||||
{
|
||||
key: 'offline',
|
||||
label: t('side_panel.offline'),
|
||||
friends: offlineFriends.value
|
||||
}
|
||||
]);
|
||||
|
||||
const friendById = computed(() => {
|
||||
const map = new Map();
|
||||
for (const friend of vipFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of onlineFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of activeFriends.value) map.set(friend.id, friend);
|
||||
for (const friend of offlineFriends.value) map.set(friend.id, friend);
|
||||
for (const section of friendSections.value) {
|
||||
for (const friend of section.friends ?? []) {
|
||||
map.set(friend.id, friend);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
@@ -714,7 +738,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
const addFriendGroup = (key, label, friends) => {
|
||||
const addFriendGroup = ({ key, label, friends }) => {
|
||||
if (!friends?.length) return;
|
||||
groups.push({
|
||||
key,
|
||||
@@ -732,10 +756,7 @@
|
||||
});
|
||||
};
|
||||
|
||||
addFriendGroup('vip', t('side_panel.favorite'), vipFriends.value);
|
||||
addFriendGroup('online', t('side_panel.online'), onlineFriends.value);
|
||||
addFriendGroup('active', t('side_panel.active'), activeFriends.value);
|
||||
addFriendGroup('offline', t('side_panel.offline'), offlineFriends.value);
|
||||
friendSections.value.forEach(addFriendGroup);
|
||||
|
||||
return groups;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user