Skip to content

Commit

Permalink
load project into separate workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Entkenntnis committed Apr 27, 2022
1 parent bde84bb commit 9295bbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
showResearchCenter,
} from '../lib/commands/researchCenter'
import { deserialize } from '../lib/commands/json'
import { WorkspaceState } from '../lib/state/types'

export function App() {
const core = useCreateCore()
Expand All @@ -22,11 +23,20 @@ export function App() {

const file = parameterList.get('project')

if (file && core.ws.type == 'free') {
if (file) {
try {
;(async () => {
const res = await fetch(file)
const text = await res.text()
const wsClone: WorkspaceState = JSON.parse(JSON.stringify(core.ws))
const title = file.match(/\/([^\/]+\.json)/)
if (title) {
wsClone.title = title[1]
}
core.mutateCore((state) => {
state.workspaces.splice(1, 0, wsClone)
state.currentWorkspace = 1
})
deserialize(core, text)
})()
} catch (e) {}
Expand Down
4 changes: 3 additions & 1 deletion components/Research.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export function Research() {
switchToWorkspace(core, i)
}}
>
<p className="text-center mt-3 font-bold">{ws.title}</p>
<p className="text-center mt-3 font-bold text-ellipsis overflow-hidden">
{ws.title}
</p>
<div className="px-3 mt-2">
<img src="/levels/preview_free.png" alt="Vorschau" />
</div>
Expand Down

0 comments on commit 9295bbd

Please sign in to comment.