Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotoNomad0 committed Nov 15, 2023
1 parent bc99eb0 commit e144db8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gitea-react-toolkit",
"version": "2.3.0",
"version": "2.4.0-beta",
"license": "MIT",
"description": "A Gitea API React Toolkit Component Library",
"homepage": "https://gitea-react-toolkit.netlify.com/",
Expand Down
22 changes: 16 additions & 6 deletions src/components/file/useEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function useEdit({
* during the save.
* @async
* @param {string} _branch - branch name to save content to
* @param {string} newContent - Stringified content to be saved to DCS
* @param {string} newContent - optional Stringified content to be saved to DCS, if not passed then value in content will be used
* @returns {Promise<boolean>} - Returns true if successful, otherwise false.
*/
async function onSaveEdit(_branch, newContent='') {
Expand All @@ -109,10 +109,20 @@ export default function useEdit({
}
}

async function onSaveEditPatch(_branch) {
/**
* Saves a patch to given branch and catches any errors that happen
* during the save.
* @async
* @param {string} _branch - branch name to save content to
* @param {string} newContent - optional patched content to be saved to DCS, if not passed then value in content will be used
* @param {string|null} fileSha - optional file sha to be used, if not passed then sha will be used
* @returns {Promise<boolean>} - Returns true if successful, otherwise false.
*/
async function onSaveEditPatch(_branch, newContent= '', fileSha = null) {
try {
// content is the updated string or dirty content.
if (content) {
const _content = newContent || content
const _sha = fileSha || sha
if (_content) {
// clear state to remove left over state from a previous edit.
setState((prevState) => ({
...prevState,
Expand All @@ -122,13 +132,13 @@ export default function useEdit({
}))

const response = await patchContent({
sha,
sha: _sha,
repo,
owner,
config,
author,
email,
content,
content: _content,
filepath,
message: _message,
// Use branch passed to function or branch passed to custom hook.
Expand Down

0 comments on commit e144db8

Please sign in to comment.