mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-19 02:51:47 +08:00
fix(server): realtime module not loaded (#14952)
#### PR Dependency Tree * **PR #14952** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Optimized workspace invite link fetching by separating it from general workspace configuration queries for improved performance. * Reorganized transcription-related backend modules to better separate concerns and enable real-time functionality. * **Chores** * Updated generated GraphQL types and iOS query definitions to reflect API changes. [](https://app.coderabbit.ai/change-stack/toeverything/AFFiNE/pull/14952) <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
+1
-27
@@ -7,7 +7,7 @@ public class GetWorkspaceConfigQuery: GraphQLQuery {
|
||||
public static let operationName: String = "getWorkspaceConfig"
|
||||
public static let operationDocument: ApolloAPI.OperationDocument = .init(
|
||||
definition: .init(
|
||||
#"query getWorkspaceConfig($id: String!) { workspace(id: $id) { __typename enableAi enableSharing enableUrlPreview enableDocEmbedding inviteLink { __typename link expireTime } } }"#
|
||||
#"query getWorkspaceConfig($id: String!) { workspace(id: $id) { __typename enableAi enableSharing enableUrlPreview enableDocEmbedding } }"#
|
||||
))
|
||||
|
||||
public var id: String
|
||||
@@ -47,7 +47,6 @@ public class GetWorkspaceConfigQuery: GraphQLQuery {
|
||||
.field("enableSharing", Bool.self),
|
||||
.field("enableUrlPreview", Bool.self),
|
||||
.field("enableDocEmbedding", Bool.self),
|
||||
.field("inviteLink", InviteLink?.self),
|
||||
] }
|
||||
public static var __fulfilledFragments: [any ApolloAPI.SelectionSet.Type] { [
|
||||
GetWorkspaceConfigQuery.Data.Workspace.self
|
||||
@@ -61,31 +60,6 @@ public class GetWorkspaceConfigQuery: GraphQLQuery {
|
||||
public var enableUrlPreview: Bool { __data["enableUrlPreview"] }
|
||||
/// Enable doc embedding
|
||||
public var enableDocEmbedding: Bool { __data["enableDocEmbedding"] }
|
||||
/// invite link for workspace
|
||||
public var inviteLink: InviteLink? { __data["inviteLink"] }
|
||||
|
||||
/// Workspace.InviteLink
|
||||
///
|
||||
/// Parent Type: `InviteLink`
|
||||
public struct InviteLink: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.InviteLink }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("__typename", String.self),
|
||||
.field("link", String.self),
|
||||
.field("expireTime", AffineGraphQL.DateTime.self),
|
||||
] }
|
||||
public static var __fulfilledFragments: [any ApolloAPI.SelectionSet.Type] { [
|
||||
GetWorkspaceConfigQuery.Data.Workspace.InviteLink.self
|
||||
] }
|
||||
|
||||
/// Invite link
|
||||
public var link: String { __data["link"] }
|
||||
/// Invite link expire time
|
||||
public var expireTime: AffineGraphQL.DateTime { __data["expireTime"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -85,6 +85,12 @@ export const CloudWorkspaceMembersPanel = ({
|
||||
membersService.members.revalidate();
|
||||
}, [membersService]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOwnerOrAdmin) {
|
||||
workspaceShareSettingService.sharePreview.revalidateInviteLink();
|
||||
}
|
||||
}, [isOwnerOrAdmin, workspaceShareSettingService.sharePreview]);
|
||||
|
||||
const workspaceQuotaService = useService(WorkspaceQuotaService);
|
||||
useEffect(() => {
|
||||
workspaceQuotaService.quota.revalidate();
|
||||
@@ -178,7 +184,7 @@ export const CloudWorkspaceMembersPanel = ({
|
||||
const onGenerateInviteLink = useCallback(
|
||||
async (expireTime: WorkspaceInviteLinkExpireTime) => {
|
||||
const { link } = await membersService.generateInviteLink(expireTime);
|
||||
workspaceShareSettingService.sharePreview.revalidate();
|
||||
workspaceShareSettingService.sharePreview.revalidateInviteLink();
|
||||
return link;
|
||||
},
|
||||
[membersService, workspaceShareSettingService.sharePreview]
|
||||
@@ -186,7 +192,7 @@ export const CloudWorkspaceMembersPanel = ({
|
||||
|
||||
const onRevokeInviteLink = useCallback(async () => {
|
||||
const success = await membersService.revokeInviteLink();
|
||||
workspaceShareSettingService.sharePreview.revalidate();
|
||||
workspaceShareSettingService.sharePreview.revalidateInviteLink();
|
||||
return success;
|
||||
}, [membersService, workspaceShareSettingService.sharePreview]);
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ export class WorkspaceShareSetting extends Entity {
|
||||
this.enableAi$.next(value.enableAi);
|
||||
this.enableSharing$.next(value.enableSharing);
|
||||
this.enableUrlPreview$.next(value.enableUrlPreview);
|
||||
this.inviteLink$.next(value.inviteLink);
|
||||
}
|
||||
}),
|
||||
catchErrorInto(this.error$, error => {
|
||||
@@ -64,6 +63,22 @@ export class WorkspaceShareSetting extends Entity {
|
||||
})
|
||||
);
|
||||
|
||||
revalidateInviteLink = effect(
|
||||
exhaustMap(() => {
|
||||
return fromPromise(signal =>
|
||||
this.store.fetchInviteLink(this.workspaceService.workspace.id, signal)
|
||||
).pipe(
|
||||
smartRetry(),
|
||||
tap(value => {
|
||||
this.inviteLink$.next(value);
|
||||
}),
|
||||
catchErrorInto(this.error$, error => {
|
||||
logger.error('Failed to fetch workspace invite link', error);
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
async waitForRevalidation(signal?: AbortSignal) {
|
||||
this.revalidate();
|
||||
await this.isLoading$.waitFor(isLoading => !isLoading, signal);
|
||||
@@ -95,5 +110,6 @@ export class WorkspaceShareSetting extends Entity {
|
||||
|
||||
override dispose(): void {
|
||||
this.revalidate.unsubscribe();
|
||||
this.revalidateInviteLink.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { WorkspaceServerService } from '@affine/core/modules/cloud';
|
||||
import {
|
||||
getWorkspaceConfigQuery,
|
||||
getWorkspaceInviteLinkQuery,
|
||||
setEnableAiMutation,
|
||||
setEnableSharingMutation,
|
||||
setEnableUrlPreviewMutation,
|
||||
@@ -28,6 +29,22 @@ export class WorkspaceShareSettingStore extends Store {
|
||||
return data.workspace;
|
||||
}
|
||||
|
||||
async fetchInviteLink(workspaceId: string, signal?: AbortSignal) {
|
||||
if (!this.workspaceServerService.server) {
|
||||
throw new Error('No Server');
|
||||
}
|
||||
const data = await this.workspaceServerService.server.gql({
|
||||
query: getWorkspaceInviteLinkQuery,
|
||||
variables: {
|
||||
id: workspaceId,
|
||||
},
|
||||
context: {
|
||||
signal,
|
||||
},
|
||||
});
|
||||
return data.workspace.inviteLink;
|
||||
}
|
||||
|
||||
async updateWorkspaceEnableAi(
|
||||
workspaceId: string,
|
||||
enableAi: boolean,
|
||||
|
||||
Reference in New Issue
Block a user