Skip to content

Commit 72bb3dd

Browse files
author
ci-bot
committed
ensure learneth workspace is created
1 parent b0ba0d2 commit 72bb3dd

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

apps/learneth/src/redux/models/remixide.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,24 @@ import { type ModelType } from '../store'
33
import remixClient from '../../remix-client'
44
import { router } from '../../App'
55
import { trackMatomoEvent } from '@remix-api'
6-
import { ensureLearnethWorkspace } from './helper-workspace'
6+
7+
const learnethWorkspaceName = 'learneth tutorials'
8+
9+
export const ensureLearnethWorkspace = async (remixClient) => {
10+
try {
11+
const current = await remixClient.call('filePanel', 'getCurrentWorkspace')
12+
if (current && current.name === learnethWorkspaceName) {
13+
return
14+
}
15+
const exists = await remixClient.call('filePanel', 'workspaceExists')
16+
if (!exists) {
17+
await remixClient.call('filePanel', 'createWorkspace', learnethWorkspaceName, 'blank')
18+
}
19+
return remixClient.call('filePanel', 'switchToWorkspace', { name: learnethWorkspaceName, isLocalHost: false })
20+
} catch (err) {
21+
console.error('Error ensuring learneth workspace:', err)
22+
}
23+
}
724

825
function getFilePath(file: string): string {
926
const name = file.split('/')

apps/remix-ide/src/app/panels/file-panel.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const profile = {
4444
'loadTemplate',
4545
'clone',
4646
'isExpanded',
47-
'isGist'
47+
'isGist',
48+
'workspaceExists'
4849
],
4950
events: ['setWorkspace', 'workspaceRenamed', 'workspaceDeleted', 'workspaceCreated'],
5051
icon: 'assets/img/fileManager.webp',
@@ -150,6 +151,11 @@ export default class Filepanel extends ViewPlugin {
150151
return this.workspaces
151152
}
152153

154+
workspaceExists(name) {
155+
if (!this.workspaces) return false
156+
return this.workspaces.find((workspace) => workspace.name === name)
157+
}
158+
153159
getAvailableWorkspaceName(name) {
154160
if (!this.workspaces) return name
155161
let index = 1

0 commit comments

Comments
 (0)