flora is a fast and secure runtime that lets you write discord bots for your servers, with a rich TypeScript SDK, without worrying about running infrastructure. [mirror]
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(frontend): use shared workspace init

+41 -30
+41 -30
apps/frontend/src/components/editor-page.tsx
··· 32 32 33 33 const WORKSPACE_SUPPORT_PATHS = new Set(Object.keys(WORKSPACE_SUPPORT_FILES)) 34 34 35 + let sharedWorkspace: Workspace | null = null 36 + let sharedWorkspaceBootstrapped = false 37 + 38 + function getSharedWorkspace() { 39 + if (sharedWorkspace) return sharedWorkspace 40 + 41 + sharedWorkspace = new Workspace({ 42 + name: 'flora-editor', 43 + initialFiles: { 44 + ...WORKSPACE_SUPPORT_FILES, 45 + 'src/main.ts': '// Loading workspace...' 46 + }, 47 + entryFile: 'src/main.ts' 48 + }) 49 + 50 + return sharedWorkspace 51 + } 52 + 35 53 function toWorkspacePath(input: string) { 36 54 return normalizePath(input.replace(/^file:\/\//, '')) 37 55 } ··· 236 254 }, [openFolders, selectedFile]) 237 255 238 256 useEffect(() => { 239 - if (workspaceRef.current) return 240 - 241 - const workspace = new Workspace({ 242 - name: guildId ? `flora-editor-${guildId}` : 'flora-editor', 243 - initialFiles: { 244 - ...WORKSPACE_SUPPORT_FILES, 245 - 'src/main.ts': '// Loading workspace...' 246 - }, 247 - entryFile: 'src/main.ts' 248 - }) 249 - 257 + const workspace = getSharedWorkspace() 250 258 workspaceRef.current = workspace 251 259 252 - lazyMonaco({ 253 - workspace, 254 - defaultTheme: 'vitesse-dark', 255 - lsp: { 256 - json: { 257 - allowComments: true, 258 - trailingCommas: 'ignore' 259 - }, 260 - typescript: { 261 - compilerOptions: { 262 - allowNonTsExtensions: true, 263 - allowSyntheticDefaultImports: true, 264 - esModuleInterop: true, 265 - resolveJsonModule: true, 266 - allowJs: true, 267 - checkJs: true 260 + if (!sharedWorkspaceBootstrapped) { 261 + lazyMonaco({ 262 + workspace, 263 + defaultTheme: 'vitesse-dark', 264 + lsp: { 265 + json: { 266 + allowComments: true, 267 + trailingCommas: 'ignore' 268 + }, 269 + typescript: { 270 + compilerOptions: { 271 + allowNonTsExtensions: true, 272 + allowSyntheticDefaultImports: true, 273 + esModuleInterop: true, 274 + resolveJsonModule: true, 275 + allowJs: true, 276 + checkJs: true 277 + } 268 278 } 269 279 } 270 - } 271 - }) 280 + }) 281 + sharedWorkspaceBootstrapped = true 282 + } 272 283 273 284 const timer = window.setTimeout(() => { 274 285 setWorkspaceReady(true) ··· 277 288 return () => { 278 289 window.clearTimeout(timer) 279 290 } 280 - }, [guildId]) 291 + }, []) 281 292 282 293 useEffect(() => { 283 294 if (!workspaceReady) return