Skip to content

Commit

Permalink
Remove splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 19, 2024
1 parent 85fe5d8 commit 3b8214c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 205 deletions.
67 changes: 29 additions & 38 deletions products/jbrowse-web/src/components/JBrowse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { observer } from 'mobx-react'
import { onSnapshot } from 'mobx-state-tree'
import { StringParam, useQueryParam } from 'use-query-params'

// core

import ShareButton from './ShareButton'

import type { WebSessionModel } from '../sessionModel'
Expand All @@ -23,61 +21,54 @@ const JBrowse = observer(function ({
const [configPath] = useQueryParam('config', StringParam)
const [, setSessionId] = useQueryParam('session', StringParam)
const { rootModel } = pluginManager
const { error, jbrowse } = rootModel || {}
const session = rootModel?.session as WebSessionModel | undefined
const currentSessionId = session?.id
const { error, jbrowse, session } = rootModel!
const { id, theme } = session! as WebSessionModel

useEffect(() => {
setSessionId(`local-${currentSessionId}`, 'replaceIn')
setSessionId(`local-${id}`, 'replaceIn')
// @ts-expect-error
window.JBrowseRootModel = rootModel
// @ts-expect-error
window.JBrowseSession = session
}, [currentSessionId, rootModel, session, setSessionId])
}, [id, rootModel, session, setSessionId])

useEffect(() => {
if (!jbrowse || !adminKey) {
return
}
return onSnapshot(jbrowse, async snapshot => {
try {
const response = await fetch(adminServer || '/updateConfig', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
adminKey,
configPath,
config: snapshot,
}),
return adminKey
? onSnapshot(jbrowse, async snapshot => {
try {
const response = await fetch(adminServer || '/updateConfig', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
adminKey,
configPath,
config: snapshot,
}),
})
if (!response.ok) {
const message = await response.text()
throw new Error(`HTTP ${response.status} (${message})`)
}
} catch (e) {
session?.notify(`Admin server error: ${e}`)
}
})
if (!response.ok) {
const message = await response.text()
throw new Error(`HTTP ${response.status} (${message})`)
}
} catch (e) {
session?.notify(`Admin server error: ${e}`)
}
})
: undefined
}, [jbrowse, session, adminKey, adminServer, configPath])

if (error) {
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw error
}
if (!rootModel) {
throw new Error('No rootModel found')
}
if (!session) {
throw new Error('No session found')
}

return (
<ThemeProvider theme={session.theme}>
<ThemeProvider theme={theme}>
<CssBaseline />
<App
// @ts-expect-error see comments on interface for AbstractSessionModel
session={session}
HeaderButtons={<ShareButton session={session} />}
// @ts-expect-error
session={session!}
// @ts-expect-error
HeaderButtons={<ShareButton session={session!} />}
/>
</ThemeProvider>
)
Expand Down
13 changes: 4 additions & 9 deletions products/jbrowse-web/src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense, lazy, useEffect, useState } from 'react'

import { FatalErrorDialog, LoadingEllipses } from '@jbrowse/core/ui'
import { FatalErrorDialog } from '@jbrowse/core/ui'
import { ErrorBoundary } from '@jbrowse/core/ui/ErrorBoundary'
import { observer } from 'mobx-react'
import {
Expand All @@ -19,7 +19,6 @@ import { createPluginManager } from '../createPluginManager'
import factoryReset from '../factoryReset'

import type { SessionLoaderModel, SessionTriagedInfo } from '../SessionLoader'
import type { WebRootModel } from '../rootModel/rootModel'
import type PluginManager from '@jbrowse/core/PluginManager'

const ConfigWarningDialog = lazy(() => import('./ConfigWarningDialog'))
Expand All @@ -35,9 +34,6 @@ export function Loader({
}: {
initialTimestamp?: number
}) {
// return value if defined, else convert null to undefined for use with
// types.maybe

const Str = StringParam

const [config] = useQueryParam('config', Str)
Expand Down Expand Up @@ -130,11 +126,10 @@ const Renderer = observer(function ({
useEffect(() => {
let pm: PluginManager | undefined
try {
if (!ready) {
return
if (ready) {
pm = createPluginManager(loader)
setPluginManager(pm)
}
pm = createPluginManager(loader)
setPluginManager(pm)
} catch (e) {
console.error(e)
setError(e)
Expand Down
117 changes: 0 additions & 117 deletions products/jbrowse-web/src/components/NewSessionCards.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion products/jbrowse-web/src/createPluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function createPluginManager(self: SessionLoaderModel) {
} else if (self.sessionSpec) {
// @ts-expect-error
afterInitializedCb = loadSessionSpec(self.sessionSpec, pluginManager)
} else if (rootModel.jbrowse.defaultSession?.views?.length) {
} else {
rootModel.setDefaultSession()
}
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ exports[`adds menus 1`] = `
"label": "Open connection...",
"onClick": [Function],
},
{
"type": "divider",
},
{
"icon": {
"$$typeof": Symbol(react.memo),
"compare": null,
"type": {
"$$typeof": Symbol(react.forward_ref),
"render": [Function],
},
},
"label": "Return to splash screen",
"onClick": [Function],
},
],
},
{
Expand Down Expand Up @@ -251,21 +236,6 @@ exports[`adds menus 2`] = `
"label": "Open connection...",
"onClick": [Function],
},
{
"type": "divider",
},
{
"icon": {
"$$typeof": Symbol(react.memo),
"compare": null,
"type": {
"$$typeof": Symbol(react.forward_ref),
"render": [Function],
},
},
"label": "Return to splash screen",
"onClick": [Function],
},
],
},
{
Expand Down
11 changes: 1 addition & 10 deletions products/jbrowse-web/src/rootModel/rootModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
InternetAccountsRootModelMixin,
} from '@jbrowse/product-core'
import AddIcon from '@mui/icons-material/Add'
import AppsIcon from '@mui/icons-material/Apps'
import ExtensionIcon from '@mui/icons-material/Extension'
import FileCopyIcon from '@mui/icons-material/FileCopy'
import FolderOpenIcon from '@mui/icons-material/FolderOpen'
Expand Down Expand Up @@ -271,7 +270,7 @@ export default function RootModel({
/**
* #action
*/
setSession(sessionSnapshot?: SnapshotIn<BaseSessionType>) {
setSession(sessionSnapshot: SnapshotIn<BaseSessionType>) {
const oldSession = self.session
self.session = cast(sessionSnapshot)
if (self.session) {
Expand Down Expand Up @@ -561,14 +560,6 @@ export default function RootModel({
)
},
},
{ type: 'divider' },
{
label: 'Return to splash screen',
icon: AppsIcon,
onClick: () => {
self.setSession(undefined)
},
},
],
},
...(adminMode
Expand Down

0 comments on commit 3b8214c

Please sign in to comment.