Merge pull request #175 from jorilallo/save-fix

Save fix
This commit is contained in:
Tom Moor
2017-07-23 18:19:10 -07:00
committed by GitHub
4 changed files with 14 additions and 16 deletions

View File

@@ -160,13 +160,13 @@ type KeyData = {
switch (data.key) {
case 's':
this.onSave(ev);
break;
return state;
case 'enter':
this.onSaveAndExit(ev);
break;
return state;
case 'escape':
this.onCancel();
break;
return state;
default:
}
};

View File

@@ -9,6 +9,7 @@ import styled from 'styled-components';
import { newDocumentUrl } from 'utils/routeHelpers';
import CollectionsStore from 'stores/CollectionsStore';
import Collection from 'models/Collection';
import CenteredContent from 'components/CenteredContent';
import LoadingListPlaceholder from 'components/LoadingListPlaceholder';
@@ -21,7 +22,7 @@ type Props = {
match: Object,
};
@observer class Collection extends React.Component {
@observer class CollectionScene extends React.Component {
props: Props;
collection: ?Collection;
@observable isFetching = true;
@@ -35,7 +36,6 @@ type Props = {
const { collections } = this.props;
const { id } = this.props.match.params;
// $FlowIssue not the correct type?
this.collection = await collections.getById(id);
if (!this.collection) this.redirectUrl = '/404';
@@ -53,14 +53,12 @@ type Props = {
<HelpText>
Publish your first document to start building your collection.
</HelpText>
<Action>
<Link
to={// $FlowIssue stupid type
newDocumentUrl(this.collection)}
>
<Button>Create new document</Button>
</Link>
</Action>
{this.collection &&
<Action>
<Link to={newDocumentUrl(this.collection)}>
<Button>Create new document</Button>
</Link>
</Action>}
</NewDocumentContainer>
);
}
@@ -85,4 +83,4 @@ const Action = styled(Flex)`
margin: 20px 0;
`;
export default inject('collections')(Collection);
export default inject('collections')(CollectionScene);

View File

@@ -40,7 +40,7 @@ router.post('documents.viewed', auth(), pagination(), async ctx => {
const views = await View.findAll({
where: { userId: user.id },
order: [[sort, direction]],
include: [{ model: Document }],
include: [{ model: Document, required: true }],
offset: ctx.state.pagination.offset,
limit: ctx.state.pagination.limit,
});

View File

@@ -36,7 +36,7 @@ async function present(ctx: Object, document: Document, options: ?Options) {
views: undefined,
};
if (document.private) {
if (document.private && document.collection) {
data.collection = await presentCollection(ctx, document.collection);
}