mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
Cleanup bulk unfriend
This commit is contained in:
@@ -89,16 +89,12 @@
|
|||||||
:table-props="{ height: 'calc(100vh - 170px)', size: 'small' }"
|
:table-props="{ height: 'calc(100vh - 170px)', size: 'small' }"
|
||||||
style="margin-top: 10px; cursor: pointer"
|
style="margin-top: 10px; cursor: pointer"
|
||||||
@row-click="selectFriendsListRow">
|
@row-click="selectFriendsListRow">
|
||||||
<el-table-column
|
<el-table-column v-if="friendsListBulkUnfriendMode" width="55">
|
||||||
v-if="friendsListBulkUnfriendMode"
|
|
||||||
:key="friendsListBulkUnfriendForceUpdate"
|
|
||||||
width="55"
|
|
||||||
prop="$selected">
|
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button text size="small" @click.stop>
|
<el-button text size="small" @click.stop>
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="row.$selected"
|
:model-value="selectedFriends.has(row.id)"
|
||||||
@change="friendsListBulkUnfriendForceUpdate++"></el-checkbox>
|
@change="toggleFriendSelection(row.id)"></el-checkbox>
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -316,7 +312,7 @@
|
|||||||
const friendsListLoading = ref(false);
|
const friendsListLoading = ref(false);
|
||||||
const friendsListLoadingProgress = ref('');
|
const friendsListLoadingProgress = ref('');
|
||||||
const friendsListSearchFilterVIP = ref(false);
|
const friendsListSearchFilterVIP = ref(false);
|
||||||
const friendsListBulkUnfriendForceUpdate = ref(0);
|
const selectedFriends = ref(new Set());
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
@@ -343,7 +339,6 @@
|
|||||||
}
|
}
|
||||||
for (const ctx of friends.value.values()) {
|
for (const ctx of friends.value.values()) {
|
||||||
if (!ctx.ref) continue;
|
if (!ctx.ref) continue;
|
||||||
ctx.ref.$selected = ctx.ref.$selected ?? false;
|
|
||||||
if (friendsListSearchFilterVIP.value && !ctx.isVIP) continue;
|
if (friendsListSearchFilterVIP.value && !ctx.isVIP) continue;
|
||||||
if (query) {
|
if (query) {
|
||||||
let match = false;
|
let match = false;
|
||||||
@@ -379,14 +374,24 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleFriendSelection(id) {
|
||||||
|
if (selectedFriends.value.has(id)) {
|
||||||
|
selectedFriends.value.delete(id);
|
||||||
|
} else {
|
||||||
|
selectedFriends.value.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleFriendsListBulkUnfriendMode() {
|
function toggleFriendsListBulkUnfriendMode() {
|
||||||
if (!friendsListBulkUnfriendMode.value) {
|
if (!friendsListBulkUnfriendMode.value) {
|
||||||
friendsListTable.data.forEach((item) => (item.$selected = false));
|
selectedFriends.value.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showBulkUnfriendSelectionConfirm() {
|
function showBulkUnfriendSelectionConfirm() {
|
||||||
const pending = friendsListTable.data.filter((item) => item.$selected).map((item) => item.displayName);
|
const pending = friendsListTable.data
|
||||||
|
.filter((item) => selectedFriends.value.has(item.id))
|
||||||
|
.map((item) => item.displayName);
|
||||||
if (!pending.length) return;
|
if (!pending.length) return;
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm(
|
||||||
`Are you sure you want to delete ${pending.length} friends?
|
`Are you sure you want to delete ${pending.length} friends?
|
||||||
@@ -410,13 +415,20 @@
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bulkUnfriendSelection() {
|
async function bulkUnfriendSelection() {
|
||||||
friendsListTable.data.forEach((item) => {
|
if (!selectedFriends.value.size) return;
|
||||||
if (item.$selected) {
|
for (const item of friendsListTable.data) {
|
||||||
|
if (selectedFriends.value.has(item.id)) {
|
||||||
console.log(`Unfriending ${item.displayName} (${item.id})`);
|
console.log(`Unfriending ${item.displayName} (${item.id})`);
|
||||||
friendRequest.deleteFriend({ userId: item.id }).then((args) => handleFriendDelete(args));
|
await friendRequest.deleteFriend({ userId: item.id }).then((args) => handleFriendDelete(args));
|
||||||
|
selectedFriends.value.delete(item.id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ElMessageBox.alert(`Unfriended ${selectedFriends.value.size} friends.`, 'Bulk Unfriend Complete', {
|
||||||
|
confirmButtonText: 'OK',
|
||||||
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
selectedFriends.value.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function friendsListLoadUsers() {
|
async function friendsListLoadUsers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user