Skip to content

Commit c96f467

Browse files
committed
[skip ci] Use dedupe
Misc UseSWR for interval polling Favs Updates Add tableContainer Misc Lint Remove update preconfigured sessions Move go button Rm Less progress Use deferred value Move files around Updates WOrking Updates Updates Updates Misc Allow sorting complete genome Delay bar Simplified More info Simplify Standardize Misc Preference Re-org Wow Aggregate field back to geneName2 Aggregate field
1 parent 5db8c54 commit c96f467

37 files changed

+1834
-792
lines changed

packages/core/ui/ConfirmDialog.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Button, DialogActions, DialogContent } from '@mui/material'
2+
import { observer } from 'mobx-react'
3+
4+
import Dialog from './Dialog'
5+
6+
import type { DialogProps } from '@mui/material'
7+
8+
interface Props extends DialogProps {
9+
header?: React.ReactNode
10+
onCancel: () => void
11+
onSubmit: () => void
12+
cancelText?: string
13+
submitText?: string
14+
}
15+
16+
const ConfirmDialog = observer(function (props: Props) {
17+
const {
18+
onSubmit,
19+
onCancel,
20+
cancelText = 'Cancel',
21+
submitText = 'OK',
22+
children,
23+
} = props
24+
return (
25+
<Dialog onClose={onCancel} {...props}>
26+
<DialogContent>{children}</DialogContent>
27+
<DialogActions>
28+
<Button
29+
color="secondary"
30+
variant="contained"
31+
onClick={() => {
32+
onCancel()
33+
}}
34+
>
35+
{cancelText}
36+
</Button>
37+
<Button
38+
color="primary"
39+
variant="contained"
40+
onClick={() => {
41+
onSubmit()
42+
}}
43+
>
44+
{submitText}
45+
</Button>
46+
</DialogActions>
47+
</Dialog>
48+
)
49+
})
50+
51+
export default ConfirmDialog

packages/core/util/cluster.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ export function clusterData({
5252
}) {
5353
// compute distance between each data point and every other data point
5454
// N x N matrix where N = data.length
55-
let start = performance.now()
55+
let stopTokenCheckerStart = performance.now()
56+
let progressStart = performance.now()
5657
const distances: number[][] = []
5758

5859
for (let i = 0; i < data.length; i++) {
59-
if (performance.now() - start > 400) {
60+
const r = performance.now()
61+
if (r - stopTokenCheckerStart > 400) {
6062
checkStopToken(stopToken)
61-
start = performance.now()
63+
stopTokenCheckerStart = performance.now()
6264
}
63-
if (onProgress) {
64-
onProgress(`Making distance matrix: ${toP(i / (data.length - 1))}%`)
65+
if (r - progressStart > 50) {
66+
onProgress?.(`Making distance matrix: ${toP(i / (data.length - 1))}%`)
67+
progressStart = performance.now()
6568
}
6669

6770
// create a row for this data point
@@ -85,14 +88,17 @@ export function clusterData({
8588
// keep track of all tree slices
8689
let clustersGivenK = []
8790

88-
start = performance.now()
91+
stopTokenCheckerStart = performance.now()
92+
progressStart = performance.now()
8993
for (let iteration = 0; iteration < data.length; iteration++) {
90-
if (performance.now() - start > 400) {
94+
const r = performance.now()
95+
if (r - stopTokenCheckerStart > 400) {
9196
checkStopToken(stopToken)
92-
start = performance.now()
97+
stopTokenCheckerStart = performance.now()
9398
}
94-
if (onProgress) {
95-
onProgress(`Clustering: ${toP((iteration + 1) / data.length)}%`)
99+
if (r - progressStart > 50) {
100+
onProgress?.(`Clustering: ${toP((iteration + 1) / data.length)}%`)
101+
progressStart = performance.now()
96102
}
97103

98104
// add current tree slice

plugins/menus/src/SessionManager/components/SessionManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const SessionManager = observer(function ({
5656
}}
5757
/>
5858
}
59-
label="Show only favorites?"
59+
label="Show favorites only?"
6060
/>
6161

6262
<Button

products/jbrowse-desktop/electron/electron.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,8 @@ interface SessionSnap {
156156

157157
let mainWindow: electron.BrowserWindow | null
158158

159-
async function updatePreconfiguredSessions() {
160-
try {
161-
const response = await fetch('https://jbrowse.org/genomes/sessions.json')
162-
if (!response.ok) {
163-
throw new Error(`HTTP ${response.status} ${response.statusText}`)
164-
}
165-
const data = await response.json()
166-
for (const [key, value] of Object.entries(data)) {
167-
// if there is not a 'gravestone' (.deleted file), then repopulate it on
168-
// startup, this allows the user to delete even defaults if they want to
169-
if (!fs.existsSync(`${getQuickstartPath(key)}.deleted`)) {
170-
fs.writeFileSync(getQuickstartPath(key), JSON.stringify(value, null, 2))
171-
}
172-
}
173-
} catch (e) {
174-
// just console.error
175-
console.error('Failed to fetch sessions.json', e)
176-
}
177-
}
178-
179159
async function createWindow() {
180160
// no need to await, just update in background
181-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
182-
updatePreconfiguredSessions()
183-
184161
const mainWindowState = windowStateKeeper({
185162
defaultWidth: 1400,
186163
defaultHeight: 800,

products/jbrowse-desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"rxjs": "^7.0.0",
9898
"sanitize-filename": "^1.6.3",
9999
"semver": "^7.3.5",
100+
"swr": "^2.3.3",
100101
"tss-react": "^4.4.1",
101102
"use-query-params": "^2.0.0"
102103
},

products/jbrowse-desktop/src/components/Loader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { observer } from 'mobx-react'
88
import { StringParam, useQueryParam } from 'use-query-params'
99

1010
import JBrowse from './JBrowse'
11-
import StartScreen from './StartScreen'
11+
import StartScreen from './StartScreen/StartScreen'
1212
import { loadPluginManager } from './StartScreen/util'
1313

1414
import type PluginManager from '@jbrowse/core/PluginManager'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Checkbox, FormControlLabel } from '@mui/material'
2+
3+
export default function Checkbox2({
4+
checked,
5+
disabled,
6+
label,
7+
onChange,
8+
className,
9+
}: {
10+
checked: boolean
11+
disabled?: boolean
12+
label: React.ReactNode
13+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
14+
className?: string
15+
}) {
16+
return (
17+
<FormControlLabel
18+
className={className}
19+
disabled={disabled}
20+
label={label}
21+
control={<Checkbox checked={checked} onChange={onChange} />}
22+
/>
23+
)
24+
}

0 commit comments

Comments
 (0)