User dialog group moderation tools

This commit is contained in:
Natsumi
2025-08-23 07:22:30 +12:00
parent af6848e409
commit 4f94582731
10 changed files with 492 additions and 194 deletions

View File

@@ -11,7 +11,11 @@ import { $app } from '../app';
import configRepository from '../service/config';
import { watchState } from '../service/watchState';
import { groupDialogFilterOptions } from '../shared/constants/';
import { replaceBioSymbols, convertFileUrlToImageUrl } from '../shared/utils';
import {
replaceBioSymbols,
convertFileUrlToImageUrl,
hasGroupPermission
} from '../shared/utils';
import { useGameStore } from './game';
import { useInstanceStore } from './instance';
import { useUserStore } from './user';
@@ -62,6 +66,21 @@ export const useGroupStore = defineStore('Group', () => {
userIds: [],
userObject: {}
},
moderateGroupDialog: {
visible: false,
groupId: '',
groupName: '',
userId: '',
userObject: {}
},
groupMemberModeration: {
visible: false,
loading: false,
id: '',
groupRef: {},
auditLogTypes: [],
openWithUserId: ''
},
cachedGroups: new Map(),
inGameGroupOrder: [],
groupInstances: [],
@@ -89,6 +108,20 @@ export const useGroupStore = defineStore('Group', () => {
}
});
const moderateGroupDialog = computed({
get: () => state.moderateGroupDialog,
set: (value) => {
state.moderateGroupDialog = value;
}
});
const groupMemberModeration = computed({
get: () => state.groupMemberModeration,
set: (value) => {
state.groupMemberModeration = value;
}
});
const cachedGroups = computed({
get: () => state.cachedGroups,
set: (value) => {
@@ -122,6 +155,8 @@ export const useGroupStore = defineStore('Group', () => {
(isLoggedIn) => {
state.groupDialog.visible = false;
state.inviteGroupDialog.visible = false;
state.moderateGroupDialog.visible = false;
state.groupMemberModeration.visible = false;
state.currentUserGroupsInit = false;
state.cachedGroups.clear();
state.currentUserGroups.clear();
@@ -1023,11 +1058,41 @@ export const useGroupStore = defineStore('Group', () => {
);
}
function showModerateGroupDialog(userId) {
const D = state.moderateGroupDialog;
D.userId = userId;
D.userObject = {};
D.visible = true;
}
function showGroupMemberModerationDialog(groupId, userId = '') {
const D = state.groupMemberModeration;
D.id = groupId;
D.openWithUserId = userId;
D.groupRef = {};
D.auditLogTypes = [];
groupRequest.getCachedGroup({ groupId }).then((args) => {
D.groupRef = args.ref;
if (hasGroupPermission(D.groupRef, 'group-audit-view')) {
groupRequest.getGroupAuditLogTypes({ groupId }).then((args) => {
if (D.id !== args.params.groupId) {
return;
}
D.auditLogTypes = args.json;
});
}
});
D.visible = true;
}
return {
state,
groupDialog,
currentUserGroups,
inviteGroupDialog,
moderateGroupDialog,
groupMemberModeration,
cachedGroups,
inGameGroupOrder,
groupInstances,
@@ -1052,6 +1117,8 @@ export const useGroupStore = defineStore('Group', () => {
handleGroupPermissions,
handleGroupMemberProps,
handleGroupList,
handleGroupRepresented
handleGroupRepresented,
showModerateGroupDialog,
showGroupMemberModerationDialog
};
});