mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
Clean up player moderations, update userDialog when unlocking someone
This commit is contained in:
@@ -1896,7 +1896,7 @@
|
||||
const { isGameRunning } = storeToRefs(useGameStore());
|
||||
const { logout } = useAuthStore();
|
||||
const { cachedConfig } = storeToRefs(useAuthStore());
|
||||
const { handlePlayerModerationAtSend, handlePlayerModeration, handlePlayerModerationDelete } = useModerationStore();
|
||||
const { applyPlayerModeration, handlePlayerModerationDelete } = useModerationStore();
|
||||
const { shiftHeld } = storeToRefs(useUiStore());
|
||||
|
||||
watch(
|
||||
@@ -2386,14 +2386,26 @@
|
||||
}
|
||||
|
||||
function handleSendPlayerModeration(args) {
|
||||
const ref = {
|
||||
json: args.json,
|
||||
params: {
|
||||
playerModerationId: args.json.id
|
||||
}
|
||||
};
|
||||
handlePlayerModeration();
|
||||
handlePlayerModerationAtSend(ref);
|
||||
const ref = applyPlayerModeration(args.json);
|
||||
const D = userDialog.value;
|
||||
if (D.visible === false || (ref.targetUserId !== D.id && ref.sourceUserId !== currentUser.value.id)) {
|
||||
return;
|
||||
}
|
||||
if (ref.type === 'block') {
|
||||
D.isBlock = true;
|
||||
} else if (ref.type === 'mute') {
|
||||
D.isMute = true;
|
||||
} else if (ref.type === 'hideAvatar') {
|
||||
D.isHideAvatar = true;
|
||||
} else if (ref.type === 'interactOff') {
|
||||
D.isInteractOff = true;
|
||||
} else if (ref.type === 'muteChat') {
|
||||
D.isMuteChat = true;
|
||||
}
|
||||
$message({
|
||||
message: t('message.user.moderated'),
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
async function performUserDialogCommand(command, userId) {
|
||||
@@ -2446,10 +2458,11 @@
|
||||
break;
|
||||
}
|
||||
case 'Moderation Unblock':
|
||||
playerModerationRequest.deletePlayerModeration({
|
||||
args = await playerModerationRequest.deletePlayerModeration({
|
||||
moderated: userId,
|
||||
type: 'block'
|
||||
});
|
||||
handlePlayerModerationDelete(args);
|
||||
break;
|
||||
case 'Moderation Block': {
|
||||
args = await playerModerationRequest.sendPlayerModeration({
|
||||
|
||||
@@ -64,51 +64,6 @@ export const useModerationStore = defineStore('Moderation', () => {
|
||||
{ flush: 'sync' }
|
||||
);
|
||||
|
||||
function handlePlayerModeration(args) {
|
||||
args.ref = applyPlayerModeration(args.json);
|
||||
const { ref } = args;
|
||||
const array = state.playerModerationTable.data;
|
||||
const { length } = array;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
if (array[i].id === ref.id) {
|
||||
Vue.set(array, i, ref);
|
||||
return;
|
||||
}
|
||||
}
|
||||
state.playerModerationTable.data.push(ref);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
function handlePlayerModerationAtSend(args) {
|
||||
const { ref } = args;
|
||||
const D = userStore.userDialog;
|
||||
if (
|
||||
D.visible === false ||
|
||||
(ref.targetUserId !== D.id &&
|
||||
ref.sourceUserId !== userStore.currentUser.id)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (ref.type === 'block') {
|
||||
D.isBlock = true;
|
||||
} else if (ref.type === 'mute') {
|
||||
D.isMute = true;
|
||||
} else if (ref.type === 'hideAvatar') {
|
||||
D.isHideAvatar = true;
|
||||
} else if (ref.type === 'interactOff') {
|
||||
D.isInteractOff = true;
|
||||
} else if (ref.type === 'muteChat') {
|
||||
D.isMuteChat = true;
|
||||
}
|
||||
$app.$message({
|
||||
message: t('message.user.moderated'),
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
function handlePlayerModerationAtDelete(args) {
|
||||
const { ref } = args;
|
||||
const D = userStore.userDialog;
|
||||
@@ -191,6 +146,13 @@ export const useModerationStore = defineStore('Moderation', () => {
|
||||
if (json.targetUserId) {
|
||||
state.cachedPlayerModerationsUserIds.add(json.targetUserId);
|
||||
}
|
||||
const array = state.playerModerationTable.data;
|
||||
const index = array.findIndex((item) => item.id === ref.id);
|
||||
if (index !== -1) {
|
||||
array[index] = ref;
|
||||
} else {
|
||||
array.push(ref);
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
@@ -238,18 +200,16 @@ export const useModerationStore = defineStore('Moderation', () => {
|
||||
}
|
||||
if (res[0]?.json) {
|
||||
for (let json of res[0].json) {
|
||||
handlePlayerModeration({
|
||||
json,
|
||||
params: {
|
||||
playerModerationId: json.id
|
||||
}
|
||||
});
|
||||
applyPlayerModeration(json);
|
||||
}
|
||||
}
|
||||
deleteExpiredPlayerModerations();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to load player/avatar moderations:', error);
|
||||
console.error(
|
||||
'Failed to load player/avatar moderations:',
|
||||
error
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -261,8 +221,7 @@ export const useModerationStore = defineStore('Moderation', () => {
|
||||
playerModerationTable,
|
||||
|
||||
refreshPlayerModerations,
|
||||
handlePlayerModerationAtSend,
|
||||
handlePlayerModeration,
|
||||
applyPlayerModeration,
|
||||
handlePlayerModerationDelete
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1000,7 +1000,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
if (!D.visible) {
|
||||
return;
|
||||
}
|
||||
const L = parseLocation(D.ref.$location.tag);
|
||||
const L = parseLocation(D.ref.$location?.tag);
|
||||
if (updateInstanceOccupants && L.isRealInstance) {
|
||||
instanceRequest.getInstance({
|
||||
worldId: L.worldId,
|
||||
|
||||
Reference in New Issue
Block a user