Don't count a view when entering editing
This commit is contained in:
@@ -104,7 +104,7 @@ type Props = {
|
|||||||
this.props.ui.setActiveDocument(document);
|
this.props.ui.setActiveDocument(document);
|
||||||
// Cache data if user enters edit mode and cancels
|
// Cache data if user enters edit mode and cancels
|
||||||
this.editCache = document.text;
|
this.editCache = document.text;
|
||||||
document.view();
|
if (!this.isEditing) document.view();
|
||||||
|
|
||||||
// Update url to match the current one
|
// Update url to match the current one
|
||||||
this.props.history.replace(
|
this.props.history.replace(
|
||||||
@@ -117,6 +117,12 @@ type Props = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get isEditing() {
|
||||||
|
return (
|
||||||
|
this.props.match.path === matchDocumentEdit || this.props.newDocument
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
get document() {
|
get document() {
|
||||||
if (this.newDocument) return this.newDocument;
|
if (this.newDocument) return this.newDocument;
|
||||||
return this.props.documents.getByUrl(
|
return this.props.documents.getByUrl(
|
||||||
@@ -200,7 +206,6 @@ type Props = {
|
|||||||
render() {
|
render() {
|
||||||
const isNew = this.props.newDocument;
|
const isNew = this.props.newDocument;
|
||||||
const isMoving = this.props.match.path === matchDocumentMove;
|
const isMoving = this.props.match.path === matchDocumentMove;
|
||||||
const isEditing = this.props.match.path === matchDocumentEdit || isNew;
|
|
||||||
const isFetching = !this.document;
|
const isFetching = !this.document;
|
||||||
const titleText = get(this.document, 'title', '');
|
const titleText = get(this.document, 'title', '');
|
||||||
const document = this.document;
|
const document = this.document;
|
||||||
@@ -231,7 +236,7 @@ type Props = {
|
|||||||
onDragEnter={this.onStartDragging}
|
onDragEnter={this.onStartDragging}
|
||||||
onDragLeave={this.onStopDragging}
|
onDragLeave={this.onStopDragging}
|
||||||
onDrop={this.onStopDragging}
|
onDrop={this.onStopDragging}
|
||||||
disabled={isEditing}
|
disabled={this.isEditing}
|
||||||
>
|
>
|
||||||
<Flex justify="center" auto>
|
<Flex justify="center" auto>
|
||||||
<Prompt
|
<Prompt
|
||||||
@@ -247,15 +252,19 @@ type Props = {
|
|||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
onSave={this.onSave}
|
onSave={this.onSave}
|
||||||
onCancel={this.onCancel}
|
onCancel={this.onCancel}
|
||||||
readOnly={!isEditing}
|
readOnly={!this.isEditing}
|
||||||
/>
|
/>
|
||||||
<Meta align="center" justify="flex-end" readOnly={!isEditing}>
|
<Meta
|
||||||
|
align="center"
|
||||||
|
justify="flex-end"
|
||||||
|
readOnly={!this.isEditing}
|
||||||
|
>
|
||||||
<Flex align="center">
|
<Flex align="center">
|
||||||
{!isNew &&
|
{!isNew &&
|
||||||
!isEditing &&
|
!this.isEditing &&
|
||||||
<Collaborators document={document} />}
|
<Collaborators document={document} />}
|
||||||
<HeaderAction>
|
<HeaderAction>
|
||||||
{isEditing
|
{this.isEditing
|
||||||
? <SaveAction
|
? <SaveAction
|
||||||
isSaving={this.isSaving}
|
isSaving={this.isSaving}
|
||||||
onClick={this.onSave.bind(this, true)}
|
onClick={this.onSave.bind(this, true)}
|
||||||
@@ -269,16 +278,17 @@ type Props = {
|
|||||||
Edit
|
Edit
|
||||||
</a>}
|
</a>}
|
||||||
</HeaderAction>
|
</HeaderAction>
|
||||||
{isEditing &&
|
{this.isEditing &&
|
||||||
<HeaderAction>
|
<HeaderAction>
|
||||||
<a onClick={this.onCancel}>Cancel</a>
|
<a onClick={this.onCancel}>Cancel</a>
|
||||||
</HeaderAction>}
|
</HeaderAction>}
|
||||||
|
{!this.isEditing &&
|
||||||
|
<HeaderAction>
|
||||||
|
<DocumentMenu document={document} />
|
||||||
|
</HeaderAction>}
|
||||||
|
{!this.isEditing && <Separator />}
|
||||||
<HeaderAction>
|
<HeaderAction>
|
||||||
<DocumentMenu document={document} />
|
{!this.isEditing &&
|
||||||
</HeaderAction>
|
|
||||||
{!isEditing && <Separator />}
|
|
||||||
<HeaderAction>
|
|
||||||
{!isEditing &&
|
|
||||||
<a onClick={this.onClickNew}>
|
<a onClick={this.onClickNew}>
|
||||||
New
|
New
|
||||||
</a>}
|
</a>}
|
||||||
|
|||||||
Reference in New Issue
Block a user