Skip to content

Commit 4a0e27d

Browse files
authored
Merge pull request #1368 from swagger-api/feature/marker-updates
update markers to accept immutable
2 parents 74be6a6 + fd9a147 commit 4a0e27d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/plugins/editor/components/editor.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { PropTypes } from "react"
22
import AceEditor from "react-ace"
33
import editorPluginsHook from "../editor-plugins/hook"
44
import { placeMarkerDecorations } from "../editor-helpers/marker-placer"
5-
import { fromJS } from "immutable"
5+
import Im, { fromJS } from "immutable"
66
import ImPropTypes from "react-immutable-proptypes"
77

88
import eq from "lodash/eq"
@@ -132,15 +132,14 @@ export default function makeEditor({ editorPluginsToRun }) {
132132
let { state } = this
133133
let { onMarkerLineUpdate } = nextProps
134134

135-
let size = obj => Object.keys(obj).length
136-
137135
// FIXME: this is a hacky solution.
138136
// we should find a way to wait until the spec has been loaded into ACE.
139-
if(force === true || (this.props.specId !== nextProps.specId || size(this.props.markers) !== size(nextProps.markers))) {
137+
if(force === true || this.props.specId !== nextProps.specId || !Im.is(this.props.markers, nextProps.markers)) {
138+
const markers = Im.Map.isMap(nextProps.markers) ? nextProps.markers.toJS() : {}
140139
setTimeout(placeMarkerDecorations.bind(null, {
141140
editor: state.editor,
142-
markers: nextProps.markers,
143-
onMarkerLineUpdate
141+
markers,
142+
onMarkerLineUpdate,
144143
}), 300)
145144
}
146145
}

0 commit comments

Comments
 (0)