fix(composer): reduction in composer bootup time

This commit is contained in:
Evan Morikawa 2016-05-17 15:03:49 -07:00
parent 517a9cdd47
commit 0db70868a8
5 changed files with 12 additions and 10 deletions

View file

@ -55,7 +55,7 @@ export default class ComposerView extends React.Component {
constructor(props) {
super(props)
this.state = {
showQuotedText: false,
showQuotedText: Utils.isForwardedMessage(props.draft),
}
}
@ -69,6 +69,11 @@ export default class ComposerView extends React.Component {
if (newProps.session !== this.props.session) {
this._receivedNewSession();
}
if (Utils.isForwardedMessage(this.props.draft) !== Utils.isForwardedMessage(newProps.draft)) {
this.setState({
showQuotedText: Utils.isForwardedMessage(newProps.draft),
});
}
}
componentDidUpdate() {
@ -118,10 +123,6 @@ export default class ComposerView extends React.Component {
this.undoManager = new UndoManager();
this._saveToHistory();
this.setState({
showQuotedText: Utils.isForwardedMessage(this.props.draft),
});
this.props.draft.files.forEach((file) => {
if (Utils.shouldDisplayAsImage(file)) {
Actions.fetchFile(file);

View file

@ -24,7 +24,7 @@ function InflatesDraftClientId(ComposedComponent) {
};
}
componentWillMount() {
componentDidMount() {
this._unmounted = false;
this._prepareForDraft(this.props.draftClientId);
}

View file

@ -170,9 +170,9 @@ class ComponentRegistry
# high-level components (like the <Sheet />) listen and re-render when
# this triggers.
#
# We set the debouce interval to 2 "frames" (33ms) to balance
# We set the debouce interval to 1 "frame" (16ms) to balance
# responsiveness and efficient batching.
triggerDebounced: _.debounce(( -> @trigger(@)), 33)
triggerDebounced: _.debounce(( -> @trigger(@)), 16)
_removeDeprecatedRoles: (displayName, roles) ->
newRoles = _.clone(roles)

View file

@ -19,6 +19,7 @@ class SizeToFitInput extends React.Component
@_sizeToFit()
_sizeToFit: =>
return if @props.value.length is 0
# Measure the width of the text in the input and
# resize the input field to fit.
input = ReactDOM.findDOMNode(@refs.input)
@ -33,7 +34,7 @@ class SizeToFitInput extends React.Component
render: =>
<span>
<span ref="measure" style={visibility:'hidden', position: 'absolute'}></span>
<input ref="input" type="text" {...@props}/>
<input ref="input" type="text" style={width: 1} {...@props}/>
</span>
select: =>

View file

@ -162,7 +162,7 @@ class Toolbar extends React.Component
shouldComponentUpdate: (nextProps, nextState) =>
# This is very important. Because toolbar uses ReactCSSTransitionGroup,
# repetitive unnecessary updates can break animations and cause performance issues.
not _.isEqual(nextProps, @props) or not _.isEqual(nextState, @state)
not Utils.isEqualReact(nextProps, @props) or not Utils.isEqualReact(nextState, @state)
render: =>
style =