mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-22 16:23:50 +02:00
* feat: Friends Sidebar Group By Instance * fix and improve performance of filter data * rm log
This commit is contained in:
89
src/app.js
89
src/app.js
@@ -185,6 +185,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.checkForVRCXUpdate();
|
||||
}
|
||||
await AppApi.CheckGameRunning();
|
||||
this.isSidebarGroupByInstance =
|
||||
(await configRepository.getBool(
|
||||
'VRCX_sidebarGroupByInstance'
|
||||
)) ?? true;
|
||||
this.isGameNoVR = await configRepository.getBool('isGameNoVR');
|
||||
await AppApi.SetAppLauncherSettings(
|
||||
this.enableAppLauncher,
|
||||
@@ -23108,6 +23112,91 @@ console.log(`isLinux: ${LINUX}`);
|
||||
return LINUX;
|
||||
};
|
||||
|
||||
// friendsListSiderBar
|
||||
$app.methods.handleSwitchGroupByInstance = async function () {
|
||||
this.isSidebarGroupByInstance = !this.isSidebarGroupByInstance;
|
||||
await configRepository.setBool(
|
||||
'VRCX_sidebarGroupByInstance',
|
||||
this.isSidebarGroupByInstance
|
||||
);
|
||||
};
|
||||
|
||||
// friendsListSidebar
|
||||
// - SidebarGroupByInstance
|
||||
|
||||
$app.data.isSidebarGroupByInstance = true;
|
||||
$app.computed.onlineFriendsInSameInstance = function () {
|
||||
const groupedItems = {};
|
||||
|
||||
this.onlineFriends.forEach((item) => {
|
||||
const key = item.ref?.$location.tag;
|
||||
if (!key || key === 'private' || key === 'offline') return;
|
||||
if (!groupedItems[key]) {
|
||||
groupedItems[key] = [];
|
||||
}
|
||||
groupedItems[key].push(item);
|
||||
});
|
||||
|
||||
const sortedGroups = [];
|
||||
for (const group of Object.values(groupedItems)) {
|
||||
if (group.length > 1) {
|
||||
sortedGroups.push(
|
||||
group.sort(
|
||||
(a, b) => a.ref?.$location_at - b.ref?.$location_at
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return sortedGroups.sort((a, b) => b.length - a.length);
|
||||
};
|
||||
|
||||
$app.computed.onlineFriendsNotInSameInstance = function () {
|
||||
const friendsInSameInstance = new Set(
|
||||
this.onlineFriendsInSameInstance.flat().map((friend) => friend.id)
|
||||
);
|
||||
|
||||
return this.onlineFriends.filter(
|
||||
(friend) => !friendsInSameInstance.has(friend.id)
|
||||
);
|
||||
};
|
||||
|
||||
$app.computed.vipFriendsInSameInstance = function () {
|
||||
const groupedItems = {};
|
||||
|
||||
this.vipFriends.forEach((item) => {
|
||||
const key = item.ref?.$location.tag;
|
||||
if (!key || key === 'private' || key === 'offline') return;
|
||||
if (!groupedItems[key]) {
|
||||
groupedItems[key] = [];
|
||||
}
|
||||
groupedItems[key].push(item);
|
||||
});
|
||||
|
||||
const sortedGroups = [];
|
||||
for (const group of Object.values(groupedItems)) {
|
||||
if (group.length > 1) {
|
||||
sortedGroups.push(
|
||||
group.sort(
|
||||
(a, b) => a.ref?.$location_at - b.ref?.$location_at
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return sortedGroups.sort((a, b) => b.length - a.length);
|
||||
};
|
||||
|
||||
$app.computed.vipFriendsNotInSameInstance = function () {
|
||||
const friendsInSameInstance = new Set(
|
||||
this.vipFriendsInSameInstance.flat().map((friend) => friend.id)
|
||||
);
|
||||
|
||||
return this.vipFriends.filter(
|
||||
(friend) => !friendsInSameInstance.has(friend.id)
|
||||
);
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region | Electron
|
||||
|
||||
Reference in New Issue
Block a user