Skip to content

Commit

Permalink
fix: gui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
4e6 committed May 20, 2024
1 parent 891fb49 commit 4cad2dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
20 changes: 15 additions & 5 deletions app/gui2/src/stores/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,27 @@ import * as Y from 'yjs'
interface LsUrls {
rpcUrl: string
dataUrl: string
ydocUrl: string
ydocUrl: URL
}

function resolveLsUrl(config: GuiConfig): LsUrls {
const engine = config.engine
if (engine == null) throw new Error('Missing engine configuration')
if (engine.rpcUrl != null && engine.dataUrl != null && engine.ydocUrl != null) {
if (engine.rpcUrl != null && engine.dataUrl != null) {
const dataUrl = engine.dataUrl
const rpcUrl = engine.rpcUrl
const ydocUrl = engine.ydocUrl

let ydocUrl: URL;
if (engine.ydocUrl == '') {
ydocUrl = new URL(location.origin)
ydocUrl.protocol = location.protocol.replace(/^http/, 'ws')
} else if (URL.canParse(engine.ydocUrl)) {
ydocUrl = new URL(engine.ydocUrl)
} else {
ydocUrl = new URL(rpcUrl)
ydocUrl.port = '1234'
}
ydocUrl.pathname = '/project'

return {
rpcUrl,
Expand Down Expand Up @@ -136,11 +147,10 @@ export const useProjectStore = defineStore('project', () => {
return tryQualifiedName(`${fullName.value}.${withDotSeparators}`)
})

const ydocUrl = new URL(lsUrls.ydocUrl)
let yDocsProvider: ReturnType<typeof attachProvider> | undefined
watchEffect((onCleanup) => {
yDocsProvider = attachProvider(
ydocUrl.href,
lsUrls.ydocUrl.href,
'index',
{ ls: lsUrls.rpcUrl },
doc,
Expand Down
14 changes: 2 additions & 12 deletions app/ide-desktop/lib/dashboard/src/layouts/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,7 @@ export default function Editor(props: EditorProps) {
} else if (binaryAddress == null) {
toastAndLog('noBinaryEndpointError')
} else {
let ydocAddress: URL
if (ydocUrl == null) {
ydocAddress = new URL(location.origin)
ydocAddress.protocol = location.protocol.replace(/^http/, 'ws')
} else if (URL.canParse(ydocUrl)) {
ydocAddress = new URL(ydocUrl)
} else {
ydocAddress = new URL(jsonAddress)
ydocAddress.port = '1234'
}
ydocAddress.pathname = '/project'
const ydocAddress = ydocUrl ?? ''
let assetsRoot: string
switch (backendType) {
case backendModule.BackendType.remote: {
Expand All @@ -115,7 +105,7 @@ export default function Editor(props: EditorProps) {
const engineConfig = {
rpcUrl: jsonAddress,
dataUrl: binaryAddress,
ydocUrl: ydocAddress.toString(),
ydocUrl: ydocAddress,
}
const originalUrl = window.location.href
if (backendType === backendModule.BackendType.remote) {
Expand Down

0 comments on commit 4cad2dd

Please sign in to comment.