Skip to content

Commit

Permalink
Save user settings on lgv
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 27, 2022
1 parent 7a24a88 commit fbe3ae4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/core/rpc/BaseRpcDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class LazyWorker {
watchWorker(worker, this.driver.maxPingTime, rpcDriverClassName).catch(
error => {
if (this.worker) {
console.warn(
`worker did not respond, killing and generating new one ${error}`,
)
// console.warn(
// `worker did not respond, killing and generating new one ${error}`,
// )
console.error(error)
this.worker.destroy()
this.worker.status = 'killed'
this.worker.error = error
Expand Down
22 changes: 19 additions & 3 deletions plugins/linear-genome-view/src/LinearGenomeView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,22 @@ export function stateModelFactory(pluginManager: PluginManager) {
types.enumeration(['hierarchical']),
'hierarchical',
),
trackLabels: 'overlapping' as 'overlapping' | 'hidden' | 'offset',
showCenterLine: false,
showCytobandsSetting: true,
trackLabels: types.optional(
types.string,
() =>
(localStorage.getItem('trackLabelsPosition') || 'overlapping') as
| 'overlapping'
| 'hidden'
| 'offset',
),
showCenterLine: types.optional(
types.boolean,
() => Boolean(localStorage.getItem('showCenterLine')) || false,
),
showCytobandsSetting: types.optional(
types.boolean,
() => Boolean(localStorage.getItem('showCytobands')) || true,
),
}),
)
.volatile(() => ({
Expand Down Expand Up @@ -434,6 +447,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
.actions(self => ({
setShowCytobands(flag: boolean) {
self.showCytobandsSetting = flag
localStorage.setItem('showCytobands', flag)
},
setWidth(newWidth: number) {
self.volatileWidth = newWidth
Expand Down Expand Up @@ -626,10 +640,12 @@ export function stateModelFactory(pluginManager: PluginManager) {

setTrackLabels(setting: 'overlapping' | 'offset' | 'hidden') {
self.trackLabels = setting
localStorage.setItem('trackLabelsPosition', setting)
},

toggleCenterLine() {
self.showCenterLine = !self.showCenterLine
localStorage.setItem('showCenterLine', `${+self.showCenterLine}`)
},

setDisplayedRegions(regions: Region[]) {
Expand Down
2 changes: 2 additions & 0 deletions products/jbrowse-web/src/workerPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ self.window = {
addEventListener() {},
fetch: self.fetch.bind(self),
location: self.location,
localStorage: { getItem: () => {}, setItem: () => {} },
Date: self.Date,
requestIdleCallback: cb => cb(),
cancelIdleCallback: () => {},
Expand All @@ -20,6 +21,7 @@ self.document = {
return { appendChild() {} }
},
documentElement: {},
localStorage: {},
createElement() {
return {
style: {},
Expand Down

0 comments on commit fbe3ae4

Please sign in to comment.