@@ -55,7 +55,7 @@ export type SpaceConfigSaveDetails = Partial<
5555} ;
5656
5757type SpaceArgs = {
58- config : SpaceConfig ;
58+ config : SpaceConfig | undefined ;
5959 saveConfig : ( config : SpaceConfigSaveDetails ) => Promise < void > ;
6060 commitConfig : ( ) => Promise < void > ;
6161 resetConfig : ( ) => Promise < void > ;
@@ -128,14 +128,17 @@ export default function Space({
128128 const isHomebasePath = usePathHelper ( ) ;
129129 const { isMobile, showMobileContainer, viewportMobile, setMobilePreview } = useViewportManager ( ) ;
130130 const { saveLocalConfig } = useConfigManager ( saveConfig ) ;
131-
131+
132+ // Track if config is loading
133+ const isConfigLoading = isUndefined ( config ) ;
134+
132135 // Calculate layout stuff once instead of re-computing
133136 const layoutConfig = getLayoutConfig ( config ?. layoutDetails ) ;
134- const layoutFidgetIds = layoutConfig ?. layout && config . fidgetInstanceDatums
137+ const layoutFidgetIds = layoutConfig ?. layout && config ? .fidgetInstanceDatums
135138 ? extractFidgetIdsFromLayout ( layoutConfig . layout , config . fidgetInstanceDatums )
136139 : [ ] ;
137140
138-
141+
139142 // Figure out what should be visible
140143 const shouldShowFeed = ! ! feed && ( ! isMobile || ( showFeedOnMobile && ! isHomebasePath ) ) ;
141144 const shouldShowMainLayout = ! ( isMobile && showFeedOnMobile && ! isHomebasePath ) ;
@@ -155,8 +158,10 @@ export default function Space({
155158 } ) , [ commitConfig , resetConfig , setEditMode , setMobilePreview ] ) ;
156159
157160 useEffect ( ( ) => {
158- setSidebarEditable ( config . isEditable ) ;
159- } , [ config . isEditable , setSidebarEditable ] ) ;
161+ if ( config ) {
162+ setSidebarEditable ( config . isEditable ) ;
163+ }
164+ } , [ config ?. isEditable , setSidebarEditable ] ) ;
160165
161166 // Cleanup logic to remove orphaned fidgets
162167 const cleanupHasRun = React . useRef ( false ) ;
@@ -191,10 +196,10 @@ export default function Space({
191196 }
192197
193198 cleanupHasRun . current = true ;
194- } , [ config . layoutDetails , config . fidgetInstanceDatums , profile , feed , saveConfig , commitConfig ] ) ;
199+ } , [ config ? .layoutDetails , config ? .fidgetInstanceDatums , profile , feed , saveConfig , commitConfig ] ) ;
195200
196- // Props for our layout components
197- const baseLayoutProps = {
201+ // Props for our layout components (only used when config is defined)
202+ const baseLayoutProps = config ? {
198203 theme : config . theme ,
199204 fidgetInstanceDatums : config . fidgetInstanceDatums ,
200205 fidgetTrayContents : config . fidgetTrayContents ,
@@ -210,21 +215,21 @@ export default function Space({
210215 fid : config . fid ,
211216 inEditMode : ! viewportMobile && editMode ,
212217 isHomebasePath : isHomebasePath ,
213- } ;
218+ } : null ;
214219
215- const desktopViewProps = {
220+ const desktopViewProps = baseLayoutProps ? {
216221 ...baseLayoutProps ,
217222 layoutFidgetKey : getLayoutFidgetForMode ( config ?. layoutDetails , 'desktop' ) ,
218223 inEditMode : ! viewportMobile && editMode ,
219- } ;
224+ } : null ;
220225
221- const mobileLayoutProps = {
226+ const mobileLayoutProps = baseLayoutProps ? {
222227 ...baseLayoutProps ,
223228 layoutFidgetIds,
224229 isHomebasePath,
225230 hasFeed : ! ! feed ,
226231 feed,
227- } ;
232+ } : null ;
228233
229234 const mainContent = (
230235 < div className = "flex flex-col h-full" >
@@ -266,22 +271,29 @@ export default function Space({
266271 : "grow h-[calc(100vh-64px)]"
267272 }
268273 >
269- < Suspense
270- fallback = {
271- < SpaceLoading
272- hasProfile = { ! isNil ( profile ) }
273- hasFeed = { ! isNil ( feed ) }
274- />
275- }
276- >
277- { isMobile ? (
278- < MobileViewSimplified
279- { ...mobileLayoutProps }
280- />
281- ) : (
282- < DesktopView { ...desktopViewProps } />
283- ) }
284- </ Suspense >
274+ { isConfigLoading ? (
275+ < SpaceLoading
276+ hasProfile = { ! isNil ( profile ) }
277+ hasFeed = { ! isNil ( feed ) }
278+ />
279+ ) : (
280+ < Suspense
281+ fallback = {
282+ < SpaceLoading
283+ hasProfile = { ! isNil ( profile ) }
284+ hasFeed = { ! isNil ( feed ) }
285+ />
286+ }
287+ >
288+ { isMobile && mobileLayoutProps ? (
289+ < MobileViewSimplified
290+ { ...mobileLayoutProps }
291+ />
292+ ) : desktopViewProps ? (
293+ < DesktopView { ...desktopViewProps } />
294+ ) : null }
295+ </ Suspense >
296+ ) }
285297 </ div >
286298 ) }
287299 </ div >
@@ -290,7 +302,7 @@ export default function Space({
290302
291303 return (
292304 < >
293- { showMobileContainer && editMode && portalRef . current
305+ { showMobileContainer && editMode && portalRef . current && config
294306 ? createPortal (
295307 < aside
296308 id = "logo-sidebar"
@@ -321,7 +333,7 @@ export default function Space({
321333 : "user-theme-background flex flex-col"
322334 } `}
323335 style = { {
324- backgroundColor : showMobileContainer ? undefined : config . theme ?. properties . background ,
336+ backgroundColor : showMobileContainer ? undefined : config ? .theme ?. properties . background ,
325337 ...( showMobileContainer && {
326338 backgroundImage : "url('/images/space-background.png')" ,
327339 backgroundSize : 'cover' ,
@@ -332,7 +344,7 @@ export default function Space({
332344 } }
333345 >
334346 < div className = "w-full h-full transition-all duration-100 ease-out" >
335- { showMobileContainer ? (
347+ { showMobileContainer && config ? (
336348 < MobilePreview
337349 config = { config }
338350 editMode = { editMode }
@@ -349,7 +361,7 @@ export default function Space({
349361 />
350362 ) : (
351363 < >
352- < CustomHTMLBackground html = { config . theme ?. properties . backgroundHTML } />
364+ < CustomHTMLBackground html = { config ? .theme ?. properties . backgroundHTML ?? "" } />
353365 { mainContent }
354366 </ >
355367 ) }
0 commit comments