Skip to content

Commit

Permalink
Wow
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 15, 2024
1 parent 0bbe6d9 commit be8089d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ import { firstValueFrom } from 'rxjs'
import { AnyConfigurationModel } from '../../configuration'

export interface RenderArgs extends ServerSideRenderArgs {
displayModel: Record<string, unknown>
blockKey: string
}

export interface RenderArgsSerialized extends ServerSideRenderArgsSerialized {
displayModel: Record<string, unknown>
blockKey: string
}

export interface RenderArgsDeserialized
extends ServerSideRenderArgsDeserialized {
displayModel: Record<string, unknown>
blockKey: string
}

Expand All @@ -53,10 +50,6 @@ export default class ComparativeServerSideRenderer extends ServerSideRenderer {
* directly modifies the render arguments to prepare them to be serialized
* and sent to the worker.
*
* the base class replaces the `displayModel` param (which on the client is a
* MST model) with a stub that only contains the `selectedFeature`, since
* this is the only part of the track model that most renderers read.
*
* @param args - the arguments passed to render
* @returns the same object
*/
Expand All @@ -68,7 +61,7 @@ export default class ComparativeServerSideRenderer extends ServerSideRenderer {
serializeArgsInClient(args: RenderArgs) {
const deserializedArgs = {
...args,
displayModel: {},
displayModel: undefined,
}

return super.serializeArgsInClient(deserializedArgs)
Expand All @@ -80,7 +73,10 @@ export default class ComparativeServerSideRenderer extends ServerSideRenderer {
args: RenderArgs,
): ResultsDeserialized {
const deserialized = super.deserializeResultsInClient(result, args)
return { ...deserialized, blockKey: args.blockKey }
return {
...deserialized,
blockKey: args.blockKey,
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const PileupRendering = observer(function (props: {
const [movedDuringLastMouseDown, setMovedDuringLastMouseDown] =
useState(false)
const selectedRect = selectedFeatureId
? displayModel?.getFeatureByID?.(blockKey, selectedFeatureId)
? displayModel?.getFeatureByID(blockKey, selectedFeatureId)
: undefined

const highlightedFeature = featureIdUnderMouse || contextMenuFeature?.id()
const highlightedRect = highlightedFeature
? displayModel?.getFeatureByID?.(blockKey, highlightedFeature)
? displayModel?.getFeatureByID(blockKey, highlightedFeature)
: undefined

function makeRect(r: [number, number, number, number], offset = 2) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/arc/src/ArcRenderer/ArcRendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Arc({
onFeatureClick,
feature,
}: {
selectedFeatureId: string
selectedFeatureId?: string
region: Region
config: AnyConfigurationModel
onFeatureClick: (event: React.MouseEvent, featureId: string) => void
Expand Down
5 changes: 3 additions & 2 deletions plugins/wiggle/src/MultiWiggleRendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MultiWiggleRendering = observer(function (props: {
height: number
blockKey: string
sources: Source[]
displayModel: { isMultiRow: boolean }
displayModel?: { isMultiRow: boolean }
onMouseLeave?: (event: React.MouseEvent) => void
onMouseMove?: (event: React.MouseEvent, arg?: Feature) => void
onFeatureClick?: (event: React.MouseEvent, arg?: Feature) => void
Expand All @@ -33,6 +33,7 @@ const MultiWiggleRendering = observer(function (props: {
} = props
const region = regions[0]!
const ref = useRef<HTMLDivElement>(null)
const { isMultiRow } = displayModel || {}

function getFeatureUnderMouse(eventClientX: number, eventClientY: number) {
if (!ref.current) {
Expand All @@ -48,7 +49,7 @@ const MultiWiggleRendering = observer(function (props: {
const px = region.reversed ? width - offsetX : offsetX
const mouseoverBp = region.start + bpPerPx * px
let featureUnderMouse: Feature | undefined
if (displayModel.isMultiRow) {
if (isMultiRow) {
for (const feature of features.values()) {
if (feature.get('source') !== source.name) {
continue
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

0 comments on commit be8089d

Please sign in to comment.