Skip to content

Commit

Permalink
Less mods
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 3, 2025
1 parent e305909 commit 7b2af87
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/MultilevelLinearView/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
addDisposer,
cast,
Expand All @@ -7,13 +6,15 @@ import {
types,
Instance,
SnapshotIn,
getEnv,
} from 'mobx-state-tree'
import FolderOpenIcon from '@mui/icons-material/FolderOpen'
import SwapVertIcon from '@mui/icons-material/SwapVert'
import MenuIcon from '@mui/icons-material/Menu'
import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter'
import LinkIcon from '@mui/icons-material/Link'
import LinkOffIcon from '@mui/icons-material/LinkOff'
/* eslint-disable @typescript-eslint/no-explicit-any */
import BaseViewModel from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel'
import { MenuItem } from '@jbrowse/core/ui'
import { getSession } from '@jbrowse/core/util'
Expand Down Expand Up @@ -61,13 +62,9 @@ export default function stateModelFactory(pluginManager: PluginManager) {
},

get refNames() {
return [
...new Set(
self.views
.map((v) => v.staticBlocks.map((m: any) => m.refName))
.flat(),
),
]
return self.views.map((v) => [
...new Set(v.staticBlocks.map((m: any) => m.refName)),
])
},

get assemblyNames() {
Expand Down Expand Up @@ -409,6 +406,21 @@ export default function stateModelFactory(pluginManager: PluginManager) {
self.views = cast([])
self.linkViews = false
},

removeView(target: any) {
const session = getSession(self)
const pluginManager = getEnv(session)
// cannot remove the anchor or the overview -- needs to have minimum these two views
if (target.isAnchor === false && target.isOverview === false) {
self.views.remove(target)
session.notify(`A view has been closed`, 'info', {
name: 'undo' as any,
onClick: () => {
pluginManager.rootModel.history.undo()
},
})
}
},
}))
.actions((self) => ({
async addView(isAbove: boolean, neighbour: any) {
Expand Down

0 comments on commit 7b2af87

Please sign in to comment.