refactor(server): workspace doc query (#10042)

This commit is contained in:
forehalo
2025-02-12 08:13:07 +00:00
parent 9dcce43360
commit 53fdb1e8a5
17 changed files with 262 additions and 152 deletions

View File

@@ -117,6 +117,9 @@ export class DocGrantedUsersService extends Service {
this.grantedUsers$.next(
this.grantedUsers$.value.filter(user => user.user.id !== userId)
);
if (this.grantedUserCount$.value > 0) {
this.grantedUserCount$.next(this.grantedUserCount$.value - 1);
}
}
async updateUserRole(userId: string, role: DocRole) {
@@ -136,6 +139,14 @@ export class DocGrantedUsersService extends Service {
);
}
async updateDocDefaultRole(role: DocRole) {
return await this.store.updateDocDefaultRole({
docId: this.docService.doc.id,
workspaceId: this.workspaceService.workspace.id,
role,
});
}
override dispose(): void {
this.loadMore.unsubscribe();
}

View File

@@ -6,6 +6,8 @@ import {
grantDocUserRolesMutation,
type PaginationInput,
revokeDocUserRolesMutation,
type UpdateDocDefaultRoleInput,
updateDocDefaultRoleMutation,
updateDocUserRoleMutation,
} from '@affine/graphql';
import { Store } from '@toeverything/infra';
@@ -92,4 +94,18 @@ export class DocGrantedUsersStore extends Store {
return res.updateDocUserRole;
}
async updateDocDefaultRole(input: UpdateDocDefaultRoleInput) {
if (!this.workspaceServerService.server) {
throw new Error('No Server');
}
const res = await this.workspaceServerService.server.gql({
query: updateDocDefaultRoleMutation,
variables: {
input,
},
});
return res.updateDocDefaultRole;
}
}