Fixes for diff feedback

This commit is contained in:
Ben Gotow 2016-09-23 18:40:44 -07:00
parent 164ab4e11d
commit 6afbacfd65
8 changed files with 28 additions and 39 deletions

View file

@ -518,21 +518,25 @@ export default class ComposerView extends React.Component {
}
_onFileReceived = (filePath) => {
// called from onDrop and onPaste - assume images should be inline
Actions.addAttachment({
filePath: filePath,
messageClientId: this.props.draft.clientId,
callback: (upload) => {
onUploadCreated: (upload) => {
if (Utils.shouldDisplayAsImage(upload)) {
const {draft, session} = this.props;
const uploads = [].concat(draft.uploads);
uploads.find(u => u.id === upload.id).inline = true;
session.changes.add({uploads})
const matchingUpload = uploads.find(u => u.id === upload.id);
if (matchingUpload) {
matchingUpload.inline = true;
session.changes.add({uploads})
Actions.insertAttachmentIntoDraft({
draftClientId: draft.clientId,
uploadId: upload.id,
})
Actions.insertAttachmentIntoDraft({
draftClientId: draft.clientId,
uploadId: matchingUpload.id,
});
}
}
},
});

View file

@ -3,14 +3,8 @@ import {
ComposerExtension,
} from 'nylas-exports'
/**
* Inserts the set of Proposed Times into the body of the HTML email.
*
*/
export default class ImageUploadComposerExtension extends ComposerExtension {
static TAG_NAME = "inline-image";
static editingActions() {
return [{
action: Actions.insertAttachmentIntoDraft,
@ -32,17 +26,9 @@ export default class ImageUploadComposerExtension extends ComposerExtension {
static _onInsertAttachmentIntoDraft({editor, actionArg}) {
if (editor.draftClientId === actionArg.draftClientId) { return }
editor.insertCustomComponent("ImageUploadInlineContainer", {
editor.insertCustomComponent("InlineImageUploadContainer", {
className: `inline-container-${actionArg.uploadId}`,
uploadId: actionArg.uploadId,
})
}
static applyTransformsToDraft({draft}) {
return draft;
}
static unapplyTransformsToDraft({draft}) {
return draft
}
}

View file

@ -15,9 +15,10 @@ export default class ImageUpload extends FileUpload {
}
_onLoaded = () => {
// on load, modify our DOM just /slightly/. This gives DOM mutation listeners
// that might be watching us (for ex: when we're in an overlaid component)
// a chance to recompute the image size.
// on load, modify our DOM just /slightly/. This causes DOM mutation listeners
// watching the DOM to trigger. This is a good thing, because the image may
// change dimensions. (We use this to reflow the draft body when this component
// is within an OverlaidComponent)
const el = ReactDOM.findDOMNode(this);
if (el) {
el.classList.add('loaded');

View file

@ -3,14 +3,13 @@ import ReactDOM from 'react-dom';
import ImageUpload from './image-upload';
import fs from 'fs';
export default class ImageUploadInlineContainer extends Component {
static displayName = 'ImageUploadInlineContainer';
export default class InlineImageUploadContainer extends Component {
static displayName = 'InlineImageUploadContainer';
static propTypes = {
draft: PropTypes.object.isRequired,
session: PropTypes.object.isRequired,
uploadId: PropTypes.string.isRequired,
style: PropTypes.object,
isPreview: PropTypes.bool,
}
@ -123,8 +122,7 @@ export default class ImageUploadInlineContainer extends Component {
return (
<div
className="image-upload-inline-container"
style={this.props.style}
className="inline-image-upload-container"
onDoubleClick={this._onGoEdit}
>
<ImageUpload key={uploadId} upload={upload} />

View file

@ -19,7 +19,7 @@ import {OverlaidComposerExtension} from 'nylas-component-kit'
import ComposeButton from './compose-button';
import ComposerView from './composer-view';
import ImageUploadComposerExtension from './image-upload-composer-extension';
import ImageUploadInlineContainer from "./image-upload-inline-container";
import InlineImageUploadContainer from "./inline-image-upload-container";
const ComposerViewForDraftClientId = InflatesDraftClientId(ComposerView);
@ -123,7 +123,7 @@ export function activate() {
}
ExtensionRegistry.Composer.register(ImageUploadComposerExtension);
CustomContenteditableComponents.register("ImageUploadInlineContainer", ImageUploadInlineContainer);
CustomContenteditableComponents.register("InlineImageUploadContainer", InlineImageUploadContainer);
}
export function deactivate() {
@ -135,7 +135,7 @@ export function deactivate() {
}
ExtensionRegistry.Composer.unregister(OverlaidComposerExtension)
ExtensionRegistry.Composer.unregister(ImageUploadComposerExtension);
CustomContenteditableComponents.unregister("ImageUploadInlineContainer");
CustomContenteditableComponents.unregister("InlineImageUploadContainer");
}
export function serialize() {

View file

@ -59,7 +59,7 @@ body.platform-win32 {
}
}
.image-upload-inline-container {
.inline-image-upload-container {
display: inline-block;
.file-wrap.file-image-wrap {

View file

@ -323,7 +323,7 @@ class DraftStore
Actions.addAttachment({
filePath: path,
messageClientId: draftClientId,
callback: callback
onUploadCreated: callback
})
_onDestroyDraft: (draftClientId) =>

View file

@ -63,8 +63,8 @@ class FileUploadStore extends NylasStore
pathsToOpen.forEach (filePath) ->
Actions.addAttachment({messageClientId, filePath})
_onAddAttachment: ({messageClientId, filePath, callback, inline}) ->
callback ?= ->
_onAddAttachment: ({messageClientId, filePath, onUploadCreated, inline}) ->
onUploadCreated ?= ->
inline ?= false
@_assertIdPresent(messageClientId)
@ -81,9 +81,9 @@ class FileUploadStore extends NylasStore
.then(@_prepareTargetDir)
.then(@_copyUpload)
.then (upload) =>
@_applySessionChanges upload.messageClientId, (uploads) ->
return @_applySessionChanges upload.messageClientId, (uploads) ->
uploads.concat([upload])
.then( => callback(upload))
.then( => onUploadCreated(upload))
.catch(@_onAttachFileError)
_onRemoveAttachment: (upload) ->