feat(threads): in split mode select the first thread if none selected

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://review.inboxapp.com/D1354
This commit is contained in:
Evan Morikawa 2015-03-26 14:46:26 -04:00
parent ee51602b26
commit 3f55979beb
3 changed files with 35 additions and 24 deletions

View file

@ -1,6 +1,7 @@
Reflux = require 'reflux'
DatabaseStore = require './database-store'
NamespaceStore = require './namespace-store'
WorkspaceStore = require './workspace-store'
AddRemoveTagsTask = require '../tasks/add-remove-tags'
MarkThreadReadTask = require '../tasks/mark-thread-read'
Actions = require '../actions'
@ -18,6 +19,7 @@ ThreadStore = Reflux.createStore
@listenTo Actions.archiveCurrentThread, @_onArchiveCurrentThread
@listenTo Actions.archiveAndNext, @_onArchiveAndNext
@listenTo Actions.searchQueryCommitted, @_onSearchCommitted
@listenTo Actions.selectLayoutMode, @_autoselectForLayoutMode
@listenTo DatabaseStore, @_onDataChanged
@listenTo NamespaceStore, -> @_onNamespaceChanged()
@fetchFromCache()
@ -79,6 +81,8 @@ ThreadStore = Reflux.createStore
newSelectedId = null
Actions.selectThreadId(newSelectedId)
@_autoselectForLayoutMode()
console.log("Fetching data for thread list took #{Date.now() - start} msec")
# If we've loaded threads, remove the loading indicator.
@ -191,6 +195,10 @@ ThreadStore = Reflux.createStore
@_onArchiveCurrentThread(silent: true)
Actions.selectThreadId(newSelectedId)
_autoselectForLayoutMode: ->
if WorkspaceStore.selectedLayoutMode() is "split" and not @selectedThread()
_.defer => Actions.selectThreadId(@_items[0]?.id)
# Accessing Data
selectedTagId: ->

View file

@ -142,6 +142,7 @@ Toolbar = React.createClass
columns: []
# Add items registered to Regions in the current sheet
if @props.data?.columns[state.mode]?
for loc in @props.data.columns[state.mode]
entries = ComponentRegistry.findAllByLocationAndMode(loc.Toolbar, state.mode)
state.columns.push(entries)
@ -149,13 +150,13 @@ Toolbar = React.createClass
# Add left items registered to the Sheet instead of to a Region
for loc in [WorkspaceStore.Sheet.Global, @props.data]
entries = ComponentRegistry.findAllByLocationAndMode(loc.Toolbar.Left, state.mode)
state.columns[0].push(entries...)
state.columns[0].push(view: ToolbarBack, name: 'ToolbarBack') if @props.depth > 0
state.columns[0]?.push(entries...)
state.columns[0]?.push(view: ToolbarBack, name: 'ToolbarBack') if @props.depth > 0
# Add right items registered to the Sheet instead of to a Region
for loc in [WorkspaceStore.Sheet.Global, @props.data]
entries = ComponentRegistry.findAllByLocationAndMode(loc.Toolbar.Right, state.mode)
state.columns[state.columns.length - 1].push(entries...)
state.columns[state.columns.length - 1]?.push(entries...)
state

View file

@ -92,6 +92,7 @@ Sheet = React.createClass
widest = -1
widestWidth = -1
if @props.data?.columns[state.mode]?
for location, idx in @props.data.columns[state.mode]
entries = ComponentRegistry.findAllByLocationAndMode(location, state.mode)
maxWidth = _.reduce entries, ((m,{view}) -> Math.min(view.maxWidth ? 10000, m)), 10000
@ -103,6 +104,7 @@ Sheet = React.createClass
widestWidth = maxWidth
widest = idx
if state.columns.length > 0
# Once we've accumulated all the React components for the columns,
# ensure that at least one column has a huge max-width so that the columns
# expand to fill the window. This may make items in the column unhappy, but