Skip to content

Commit

Permalink
feat: update getDocument to use new writer.getDocument format
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmacdonald committed Sep 4, 2019
1 parent 5c99e8f commit d072a3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
37 changes: 19 additions & 18 deletions src/SaveToPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,27 @@ class SaveToPath extends Component {

save = () => {
this.setState({saving: true});
const document = this.props.getDocument();
this.props.usePR ?
cwrcGit.saveAsPullRequest(this.getFullRepoPath(), this.props.path, document, this.state.prBranch, this.state.commitMessage, this.state.prTitle).then(
(result) => this.complete(),
(error) => {
if (error.statusText === 'Internal Server Error') {
error.statusText = 'You do not have pull request permissions for the selected repository. Try saving to another repository you have pull request privileges for.'
this.props.getDocument().then((document) => {
this.props.usePR ?
cwrcGit.saveAsPullRequest(this.getFullRepoPath(), this.props.path, document, this.state.prBranch, this.state.commitMessage, this.state.prTitle).then(
(result) => this.complete(),
(error) => {
if (error.statusText === 'Internal Server Error') {
error.statusText = 'You do not have pull request permissions for the selected repository. Try saving to another repository you have pull request privileges for.'
}
this.displayError(error)
}
this.displayError(error)
}
) :
cwrcGit.saveDoc(this.getFullRepoPath(), this.props.path, document, this.state.branch, this.state.commitMessage).then(
(result) => this.complete(),
(error) => {
if (error.statusText === 'Not Found') {
error.statusText = 'You do not have writing permissions for the selected repository. Try saving as a pull request or save to another repository you have writing privileges for.'
) :
cwrcGit.saveDoc(this.getFullRepoPath(), this.props.path, document, this.state.branch, this.state.commitMessage).then(
(result) => this.complete(),
(error) => {
if (error.statusText === 'Not Found') {
error.statusText = 'You do not have writing permissions for the selected repository. Try saving as a pull request or save to another repository you have writing privileges for.'
}
this.displayError(error)
}
this.displayError(error)
}
)
)
})

}

Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ function getDocumentURI() {
}

function getDocument() {
const content = _writer.getDocument(true);
return content;
return new Promise((resolve, reject) => {
_writer.getDocumentString((content) => {
resolve(content);
});
})
}

function getDocumentInfoFromLocation() {
Expand Down

0 comments on commit d072a3e

Please sign in to comment.