File tree Expand file tree Collapse file tree 8 files changed +48
-9
lines changed
core/workspaces/resolvers
common/infra/src/modules/workspace
component/src/components/workspace-list
core/src/modules/workspace-engine/impls Expand file tree Collapse file tree 8 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,21 @@ export class WorkspaceResolver {
9494 } ) ;
9595 }
9696
97+ @ResolveField ( ( ) => Boolean , {
98+ description : 'is current workspace initialized' ,
99+ complexity : 2 ,
100+ } )
101+ async initialized ( @Parent ( ) workspace : WorkspaceType ) {
102+ return this . prisma . snapshot
103+ . count ( {
104+ where : {
105+ id : workspace . id ,
106+ workspaceId : workspace . id ,
107+ } ,
108+ } )
109+ . then ( count => count > 0 ) ;
110+ }
111+
97112 @ResolveField ( ( ) => UserType , {
98113 description : 'Owner of workspace' ,
99114 complexity : 2 ,
Original file line number Diff line number Diff line change @@ -893,6 +893,9 @@ type WorkspaceType {
893893 histories (before : DateTime , guid : String ! , take : Int ): [DocHistoryType ! ]!
894894 id : ID !
895895
896+ """is current workspace initialized"""
897+ initialized : Boolean !
898+
896899 """member count of workspace"""
897900 memberCount : Int !
898901
Original file line number Diff line number Diff line change 11import type { WorkspaceFlavour } from '@affine/env/workspace' ;
22
3- export type WorkspaceMetadata = { id : string ; flavour : WorkspaceFlavour } ;
3+ export type WorkspaceMetadata = {
4+ id : string ;
5+ flavour : WorkspaceFlavour ;
6+ initialized ?: boolean ;
7+ } ;
Original file line number Diff line number Diff line change 1+ import { WorkspaceFlavour } from '@affine/env/workspace' ;
12import type { WorkspaceMetadata } from '@toeverything/infra' ;
23import { Suspense } from 'react' ;
34
@@ -58,9 +59,13 @@ const SortableWorkspaceItem = ({
5859export const WorkspaceList = ( props : WorkspaceListProps ) => {
5960 const workspaceList = props . items ;
6061
61- return workspaceList . map ( item => (
62- < Suspense fallback = { < WorkspaceCardSkeleton /> } key = { item . id } >
63- < SortableWorkspaceItem key = { item . id } { ...props } item = { item } />
64- </ Suspense >
65- ) ) ;
62+ return workspaceList
63+ . filter (
64+ w => w . flavour !== WorkspaceFlavour . AFFINE_CLOUD || w . initialized === true
65+ )
66+ . map ( item => (
67+ < Suspense fallback = { < WorkspaceCardSkeleton /> } key = { item . id } >
68+ < SortableWorkspaceItem key = { item . id } { ...props } item = { item } />
69+ </ Suspense >
70+ ) ) ;
6671} ;
Original file line number Diff line number Diff line change @@ -117,7 +117,10 @@ export class CloudWorkspaceFlavourProviderService
117117 this . revalidate ( ) ;
118118 await this . waitForLoaded ( ) ;
119119
120- return { id : workspaceId , flavour : WorkspaceFlavour . AFFINE_CLOUD } ;
120+ return {
121+ id : workspaceId ,
122+ flavour : WorkspaceFlavour . AFFINE_CLOUD ,
123+ } ;
121124 }
122125 revalidate = effect (
123126 map ( ( ) => {
@@ -138,12 +141,16 @@ export class CloudWorkspaceFlavourProviderService
138141 } ,
139142 } ) ;
140143
141- const ids = workspaces . map ( ( { id } ) => id ) ;
144+ const ids = workspaces . map ( ( { id, initialized } ) => ( {
145+ id,
146+ initialized,
147+ } ) ) ;
142148 return {
143149 accountId,
144- workspaces : ids . map ( id => ( {
150+ workspaces : ids . map ( ( { id , initialized } ) => ( {
145151 id,
146152 flavour : WorkspaceFlavour . AFFINE_CLOUD ,
153+ initialized,
147154 } ) ) ,
148155 } ;
149156 } ) . pipe (
Original file line number Diff line number Diff line change 11query getWorkspaces {
22 workspaces {
33 id
4+ initialized
45 owner {
56 id
67 }
Original file line number Diff line number Diff line change @@ -677,6 +677,7 @@ export const getWorkspacesQuery = {
677677query getWorkspaces {
678678 workspaces {
679679 id
680+ initialized
680681 owner {
681682 id
682683 }
Original file line number Diff line number Diff line change @@ -1203,6 +1203,8 @@ export interface WorkspaceType {
12031203 features : Array < FeatureType > ;
12041204 histories : Array < DocHistoryType > ;
12051205 id : Scalars [ 'ID' ] [ 'output' ] ;
1206+ /** is current workspace initialized */
1207+ initialized : Scalars [ 'Boolean' ] [ 'output' ] ;
12061208 /** member count of workspace */
12071209 memberCount : Scalars [ 'Int' ] [ 'output' ] ;
12081210 /** Members of workspace */
@@ -1843,6 +1845,7 @@ export type GetWorkspacesQuery = {
18431845 workspaces : Array < {
18441846 __typename ?: 'WorkspaceType' ;
18451847 id : string ;
1848+ initialized : boolean ;
18461849 owner : { __typename ?: 'UserType' ; id : string } ;
18471850 } > ;
18481851} ;
You can’t perform that action at this time.
0 commit comments