Skip to content

Commit

Permalink
fix addFolder delay issue
Browse files Browse the repository at this point in the history
  • Loading branch information
helamanl0424 authored Apr 1, 2024
1 parent 2cb2700 commit 11afd17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions samples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ function addFolderAction() {
if (folderName) {
console.log(`Adding folder: ${folderName}`);
addFolder(folderName).then(() => {
if (!folderName.endsWith('/')) {
folderName += '/';
}
fetchAndDisplayItems(getCurrentPath() + folderName);
alert('Folder added successfully!');
input.remove(); // Remove the input field
addFolderBtn.style.display = ''; // Show the button again
Expand Down Expand Up @@ -426,13 +422,17 @@ function removeAccessFromAction() {
}

async function addFolder(folderName) {
if (!folderName.endsWith('/')) {
folderName += '/';
}
const newPath = getCurrentPath() + folderName;
const event = `${getPicoURL()}1556/sample_app/create_folder?containerURL=${newPath}`;
fetch(event)
.then(response => {
if (!response.ok) {
throw new Error(`Add folder failed: ${response.status}`);
}
fetchAndDisplayItems(newPath);
})
.catch(error => {
console.error('Error adding folder:', error);
Expand Down

0 comments on commit 11afd17

Please sign in to comment.