fix(*): A few patches for minor sentry errors

Summary:
Fix edge cases where _getRangeInScope is null, fix logic errors

fix(1932) Edge case where we can't find a container for the message Id we're asked to scroll to

Check view exists before trying to perform actions. Will be fixed once keybindings are a React container

Test Plan: Run specs

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1906
This commit is contained in:
Ben Gotow 2015-08-18 10:31:18 -07:00
parent 07996da960
commit 941e16bb11
3 changed files with 26 additions and 24 deletions

View file

@ -481,7 +481,10 @@ class ContenteditableComponent extends React.Component
# Don't bother computing client rects if no scroll method has been provided # Don't bother computing client rects if no scroll method has been provided
else if @props.onScrollTo else if @props.onScrollTo
rect = @_getRangeInScope().getBoundingClientRect() rangeInScope = @_getRangeInScope()
return unless rangeInScope
rect = rangeInScope.getBoundingClientRect()
if @_isEmptyBoudingRect(rect) if @_isEmptyBoudingRect(rect)
rect = @_getSelectionRectFromDOM(selection) rect = @_getSelectionRectFromDOM(selection)
@ -763,31 +766,24 @@ class ContenteditableComponent extends React.Component
toolbarPos: toolbarPos toolbarPos: toolbarPos
linkToModify: @_linkHoveringOver linkToModify: @_linkHoveringOver
editAreaWidth: editAreaWidth editAreaWidth: editAreaWidth
else if not @_selection? or @_selection.isCollapsed
@_hideToolbar()
else else
if not @_selection? or @_selection.isCollapsed rect = @_getRangeInScope()?.getBoundingClientRect()
if not rect or @_isEmptyBoudingRect(rect)
@_hideToolbar() @_hideToolbar()
else else
if @_selection.isCollapsed [left, top, editAreaWidth, toolbarPos] = @_getToolbarPos(rect)
linkRect = linksInside[0].getBoundingClientRect() @setState
isEmptyRect = @_isEmptyBoudingRect(linkRect) toolbarVisible: true
[left, top, editAreaWidth, toolbarPos] = @_getToolbarPos(linkRect) toolbarMode: "buttons"
else toolbarTop: top
selectionRect = @_getRangeInScope().getBoundingClientRect() toolbarLeft: left
isEmptyRect = @_isEmptyBoudingRect(selectionRect) toolbarPos: toolbarPos
[left, top, editAreaWidth, toolbarPos] = @_getToolbarPos(selectionRect) linkToModify: null
editAreaWidth: editAreaWidth
if isEmptyRect
@setState
toolbarVisible: false
else
@setState
toolbarVisible: true
toolbarMode: "buttons"
toolbarTop: top
toolbarLeft: left
toolbarPos: toolbarPos
linkToModify: null
editAreaWidth: editAreaWidth
_selectionInScope: (selection) => _selectionInScope: (selection) =>
return false if not selection? return false if not selection?

View file

@ -383,7 +383,9 @@ class MessageList extends React.Component
_onChildScrollRequest: ({messageId, rect}={}) => _onChildScrollRequest: ({messageId, rect}={}) =>
return if @_draftScrollInProgress return if @_draftScrollInProgress
if messageId if messageId
@refs.messageWrap.scrollTo(@_getMessageContainer(messageId), { messageElement = @_getMessageContainer(messageId)
return unless messageElement
@refs.messageWrap.scrollTo(messageElement, {
position: ScrollRegion.ScrollPosition.Visible position: ScrollRegion.ScrollPosition.Visible
}) })
else if rect else if rect

View file

@ -232,6 +232,8 @@ class ThreadList extends React.Component
# Additional Commands # Additional Commands
_onStarItem: => _onStarItem: =>
return unless ThreadListStore.view()
if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
Actions.toggleStarFocused() Actions.toggleStarFocused()
else if ThreadListStore.view().selection.count() > 0 else if ThreadListStore.view().selection.count() > 0
@ -240,6 +242,8 @@ class ThreadList extends React.Component
Actions.toggleStarFocused() Actions.toggleStarFocused()
_onArchive: => _onArchive: =>
return unless ThreadListStore.view()
if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
Actions.archive() Actions.archive()
else if ThreadListStore.view().selection.count() > 0 else if ThreadListStore.view().selection.count() > 0