fix(core): adjust share menu (#10164)

close AF-2218 AF-2215 AF-2221
This commit is contained in:
JimmFly
2025-02-14 10:32:12 +00:00
parent 36800f2d24
commit 9048b38069
20 changed files with 328 additions and 184 deletions

View File

@@ -1,4 +1,4 @@
import type { DocRole, GetPageGrantedUsersListQuery } from '@affine/graphql';
import { DocRole, type GetPageGrantedUsersListQuery } from '@affine/graphql';
import {
backoffRetry,
catchErrorInto,
@@ -123,20 +123,29 @@ export class DocGrantedUsersService extends Service {
}
async updateUserRole(userId: string, role: DocRole) {
await this.store.updateDocUserRole(
const res = await this.store.updateDocUserRole(
this.workspaceService.workspace.id,
this.docService.doc.id,
userId,
role
);
this.grantedUsers$.next(
this.grantedUsers$.value.map(user => {
if (user.user.id === userId) {
return { ...user, role };
}
return user;
})
);
if (res) {
if (role === DocRole.Owner) {
this.reset();
this.loadMore();
return res;
}
this.grantedUsers$.next(
this.grantedUsers$.value.map(user => {
if (user.user.id === userId) {
return { ...user, role };
}
return user;
})
);
}
return res;
}
async updateDocDefaultRole(role: DocRole) {