refactor(server): workspace doc query (#10042)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user