mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-24 04:27:27 +08:00
@@ -94,6 +94,21 @@ export class WorkspaceResolver {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Boolean, {
|
||||||
|
description: 'is current workspace initialized',
|
||||||
|
complexity: 2,
|
||||||
|
})
|
||||||
|
async initialized(@Parent() workspace: WorkspaceType) {
|
||||||
|
return this.prisma.snapshot
|
||||||
|
.count({
|
||||||
|
where: {
|
||||||
|
id: workspace.id,
|
||||||
|
workspaceId: workspace.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(count => count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
@ResolveField(() => UserType, {
|
@ResolveField(() => UserType, {
|
||||||
description: 'Owner of workspace',
|
description: 'Owner of workspace',
|
||||||
complexity: 2,
|
complexity: 2,
|
||||||
|
|||||||
@@ -893,6 +893,9 @@ type WorkspaceType {
|
|||||||
histories(before: DateTime, guid: String!, take: Int): [DocHistoryType!]!
|
histories(before: DateTime, guid: String!, take: Int): [DocHistoryType!]!
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
|
"""is current workspace initialized"""
|
||||||
|
initialized: Boolean!
|
||||||
|
|
||||||
"""member count of workspace"""
|
"""member count of workspace"""
|
||||||
memberCount: Int!
|
memberCount: Int!
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
import type { WorkspaceFlavour } from '@affine/env/workspace';
|
import type { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
|
|
||||||
export type WorkspaceMetadata = { id: string; flavour: WorkspaceFlavour };
|
export type WorkspaceMetadata = {
|
||||||
|
id: string;
|
||||||
|
flavour: WorkspaceFlavour;
|
||||||
|
initialized?: boolean;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import type { WorkspaceMetadata } from '@toeverything/infra';
|
import type { WorkspaceMetadata } from '@toeverything/infra';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
@@ -58,9 +59,13 @@ const SortableWorkspaceItem = ({
|
|||||||
export const WorkspaceList = (props: WorkspaceListProps) => {
|
export const WorkspaceList = (props: WorkspaceListProps) => {
|
||||||
const workspaceList = props.items;
|
const workspaceList = props.items;
|
||||||
|
|
||||||
return workspaceList.map(item => (
|
return workspaceList
|
||||||
<Suspense fallback={<WorkspaceCardSkeleton />} key={item.id}>
|
.filter(
|
||||||
<SortableWorkspaceItem key={item.id} {...props} item={item} />
|
w => w.flavour !== WorkspaceFlavour.AFFINE_CLOUD || w.initialized === true
|
||||||
</Suspense>
|
)
|
||||||
));
|
.map(item => (
|
||||||
|
<Suspense fallback={<WorkspaceCardSkeleton />} key={item.id}>
|
||||||
|
<SortableWorkspaceItem key={item.id} {...props} item={item} />
|
||||||
|
</Suspense>
|
||||||
|
));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -117,7 +117,10 @@ export class CloudWorkspaceFlavourProviderService
|
|||||||
this.revalidate();
|
this.revalidate();
|
||||||
await this.waitForLoaded();
|
await this.waitForLoaded();
|
||||||
|
|
||||||
return { id: workspaceId, flavour: WorkspaceFlavour.AFFINE_CLOUD };
|
return {
|
||||||
|
id: workspaceId,
|
||||||
|
flavour: WorkspaceFlavour.AFFINE_CLOUD,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
revalidate = effect(
|
revalidate = effect(
|
||||||
map(() => {
|
map(() => {
|
||||||
@@ -138,12 +141,16 @@ export class CloudWorkspaceFlavourProviderService
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ids = workspaces.map(({ id }) => id);
|
const ids = workspaces.map(({ id, initialized }) => ({
|
||||||
|
id,
|
||||||
|
initialized,
|
||||||
|
}));
|
||||||
return {
|
return {
|
||||||
accountId,
|
accountId,
|
||||||
workspaces: ids.map(id => ({
|
workspaces: ids.map(({ id, initialized }) => ({
|
||||||
id,
|
id,
|
||||||
flavour: WorkspaceFlavour.AFFINE_CLOUD,
|
flavour: WorkspaceFlavour.AFFINE_CLOUD,
|
||||||
|
initialized,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
}).pipe(
|
}).pipe(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
query getWorkspaces {
|
query getWorkspaces {
|
||||||
workspaces {
|
workspaces {
|
||||||
id
|
id
|
||||||
|
initialized
|
||||||
owner {
|
owner {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -677,6 +677,7 @@ export const getWorkspacesQuery = {
|
|||||||
query getWorkspaces {
|
query getWorkspaces {
|
||||||
workspaces {
|
workspaces {
|
||||||
id
|
id
|
||||||
|
initialized
|
||||||
owner {
|
owner {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1203,6 +1203,8 @@ export interface WorkspaceType {
|
|||||||
features: Array<FeatureType>;
|
features: Array<FeatureType>;
|
||||||
histories: Array<DocHistoryType>;
|
histories: Array<DocHistoryType>;
|
||||||
id: Scalars['ID']['output'];
|
id: Scalars['ID']['output'];
|
||||||
|
/** is current workspace initialized */
|
||||||
|
initialized: Scalars['Boolean']['output'];
|
||||||
/** member count of workspace */
|
/** member count of workspace */
|
||||||
memberCount: Scalars['Int']['output'];
|
memberCount: Scalars['Int']['output'];
|
||||||
/** Members of workspace */
|
/** Members of workspace */
|
||||||
@@ -1843,6 +1845,7 @@ export type GetWorkspacesQuery = {
|
|||||||
workspaces: Array<{
|
workspaces: Array<{
|
||||||
__typename?: 'WorkspaceType';
|
__typename?: 'WorkspaceType';
|
||||||
id: string;
|
id: string;
|
||||||
|
initialized: boolean;
|
||||||
owner: { __typename?: 'UserType'; id: string };
|
owner: { __typename?: 'UserType'; id: string };
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user