Mailspring/internal_packages/composer/lib/main.cjsx
Evan Morikawa fc4b3b56d7 refactor(utils): switch to regular underscore
Summary:
Fixes: T1334

remove final InboxApp references

move out all underscore-plus methods

Mass find and replace of underscore-plus

sed -i '' -- 's/underscore-plus/underscore/g' **/*.coffee
sed -i '' -- 's/underscore-plus/underscore/g' **/*.cjsx

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1534
2015-05-19 16:06:59 -07:00

68 lines
1.8 KiB
CoffeeScript

_ = require 'underscore'
React = require 'react'
{NamespaceStore,
DatabaseStore,
Message,
ComponentRegistry,
WorkspaceStore} = require('nylas-exports')
NewComposeButton = require('./new-compose-button')
ComposerView = require('./composer-view')
module.exports =
activate: (@state={}) ->
atom.registerHotWindow
windowType: "composer"
replenishNum: 2
# Register our composer as the app-wide Composer
ComponentRegistry.register ComposerView,
role: 'Composer'
if atom.isMainWindow()
@_activateComposeButton()
else
@_setupContainer()
windowPropsReceived: ({draftLocalId, errorMessage}) ->
return unless @_container
React.render(
<ComposerView mode="fullwindow" localId={draftLocalId} />, @_container
)
if errorMessage
@_showInitialErrorDialog(errorMessage)
deactivate: ->
if atom.isMainWindow()
React.unmountComponentAtNode(@_composeButton)
@_composeButton.remove()
@_composeButton = null
else
React.unmountComponentAtNode(@_container)
@_container.remove()
@_container = null
serialize: -> @state
_setupContainer: ->
if @_container? then return # Activate once
@_container = document.createElement("div")
@_container.setAttribute("id", "composer-full-window")
@_container.setAttribute("class", "composer-full-window")
document.body.appendChild(@_container)
_activateComposeButton: ->
ComponentRegistry.register NewComposeButton,
location: WorkspaceStore.Location.RootSidebar.Toolbar
_showInitialErrorDialog: (msg) ->
remote = require('remote')
dialog = remote.require('dialog')
dialog.showMessageBox remote.getCurrentWindow(), {
type: 'warning'
buttons: ['Okay'],
message: "Error"
detail: msg
}