Skip to content

Commit

Permalink
Fix request body not changing (Fixes #792)
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Mar 2, 2018
1 parent eeac30b commit 903a5d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/insomnia-app/app/models/request-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export function getByParentId (parentId) {
return db.getWhere(type, {parentId});
}

export async function getOrCreateByParentId (parentId) {
const requestMeta = await getByParentId(parentId);

if (requestMeta) {
return requestMeta;
}

return create({parentId});
}

export function all () {
return db.all(type);
}
7 changes: 5 additions & 2 deletions packages/insomnia-app/app/ui/containers/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ class App extends PureComponent {
return null;
}

const requestMeta = await models.requestMeta.getByParentId(this.props.activeRequest._id);
const requestMeta = await models.requestMeta.getOrCreateByParentId(
this.props.activeRequest._id
);
const savedBody = requestMeta.savedRequestBody;

const saveValue = (typeof mimeType !== 'string') // Switched to No body
Expand Down Expand Up @@ -841,7 +843,8 @@ class App extends PureComponent {
}

return (
<KeydownBinder onKeydown={this._handleKeyDown}>
<KeydownBinder onKeydown={this._handleKeyDown}
key={this.props.activeWorkspace ? this.props.activeWorkspace._id : 'n/a'}>
<div className="app">
<ErrorBoundary showAlert>
<Wrapper
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "insomnia",
"productName": "Insomnia",
"longName": "Insomnia REST Client",
"version": "5.14.8",
"version": "5.14.9",
"main": "main.min.js"
},
"licence": "MIT",
Expand Down

0 comments on commit 903a5d7

Please sign in to comment.