mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +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 { isGameRunning } = storeToRefs(useGameStore());
|
||||||
const { logout } = useAuthStore();
|
const { logout } = useAuthStore();
|
||||||
const { cachedConfig } = storeToRefs(useAuthStore());
|
const { cachedConfig } = storeToRefs(useAuthStore());
|
||||||
const { handlePlayerModerationAtSend, handlePlayerModeration, handlePlayerModerationDelete } = useModerationStore();
|
const { applyPlayerModeration, handlePlayerModerationDelete } = useModerationStore();
|
||||||
const { shiftHeld } = storeToRefs(useUiStore());
|
const { shiftHeld } = storeToRefs(useUiStore());
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -2386,14 +2386,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSendPlayerModeration(args) {
|
function handleSendPlayerModeration(args) {
|
||||||
const ref = {
|
const ref = applyPlayerModeration(args.json);
|
||||||
json: args.json,
|
const D = userDialog.value;
|
||||||
params: {
|
if (D.visible === false || (ref.targetUserId !== D.id && ref.sourceUserId !== currentUser.value.id)) {
|
||||||
playerModerationId: args.json.id
|
return;
|
||||||
}
|
}
|
||||||
};
|
if (ref.type === 'block') {
|
||||||
handlePlayerModeration();
|
D.isBlock = true;
|
||||||
handlePlayerModerationAtSend(ref);
|
} 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) {
|
async function performUserDialogCommand(command, userId) {
|
||||||
@@ -2446,10 +2458,11 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'Moderation Unblock':
|
case 'Moderation Unblock':
|
||||||
playerModerationRequest.deletePlayerModeration({
|
args = await playerModerationRequest.deletePlayerModeration({
|
||||||
moderated: userId,
|
moderated: userId,
|
||||||
type: 'block'
|
type: 'block'
|
||||||
});
|
});
|
||||||
|
handlePlayerModerationDelete(args);
|
||||||
break;
|
break;
|
||||||
case 'Moderation Block': {
|
case 'Moderation Block': {
|
||||||
args = await playerModerationRequest.sendPlayerModeration({
|
args = await playerModerationRequest.sendPlayerModeration({
|
||||||
|
|||||||
+13
-54
@@ -64,51 +64,6 @@ export const useModerationStore = defineStore('Moderation', () => {
|
|||||||
{ flush: 'sync' }
|
{ 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) {
|
function handlePlayerModerationAtDelete(args) {
|
||||||
const { ref } = args;
|
const { ref } = args;
|
||||||
const D = userStore.userDialog;
|
const D = userStore.userDialog;
|
||||||
@@ -191,6 +146,13 @@ export const useModerationStore = defineStore('Moderation', () => {
|
|||||||
if (json.targetUserId) {
|
if (json.targetUserId) {
|
||||||
state.cachedPlayerModerationsUserIds.add(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;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,18 +200,16 @@ export const useModerationStore = defineStore('Moderation', () => {
|
|||||||
}
|
}
|
||||||
if (res[0]?.json) {
|
if (res[0]?.json) {
|
||||||
for (let json of res[0].json) {
|
for (let json of res[0].json) {
|
||||||
handlePlayerModeration({
|
applyPlayerModeration(json);
|
||||||
json,
|
|
||||||
params: {
|
|
||||||
playerModerationId: json.id
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteExpiredPlayerModerations();
|
deleteExpiredPlayerModerations();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.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,
|
playerModerationTable,
|
||||||
|
|
||||||
refreshPlayerModerations,
|
refreshPlayerModerations,
|
||||||
handlePlayerModerationAtSend,
|
applyPlayerModeration,
|
||||||
handlePlayerModeration,
|
|
||||||
handlePlayerModerationDelete
|
handlePlayerModerationDelete
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -1000,7 +1000,7 @@ export const useUserStore = defineStore('User', () => {
|
|||||||
if (!D.visible) {
|
if (!D.visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const L = parseLocation(D.ref.$location.tag);
|
const L = parseLocation(D.ref.$location?.tag);
|
||||||
if (updateInstanceOccupants && L.isRealInstance) {
|
if (updateInstanceOccupants && L.isRealInstance) {
|
||||||
instanceRequest.getInstance({
|
instanceRequest.getInstance({
|
||||||
worldId: L.worldId,
|
worldId: L.worldId,
|
||||||
|
|||||||
Reference in New Issue
Block a user