Skip to content

Commit

Permalink
refactor: replace load with a timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon committed Mar 18, 2024
1 parent 27f6d04 commit ed090fa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/FeedOutputBrowser/FileBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const FileBrowser = (props: FileBrowserProps) => {
};

const makeDataSourcePrivate = async () => {
console.log("Make it private again");
// Implement logic to make the data source private again
await feed?.put({
//@ts-ignore
Expand Down Expand Up @@ -107,17 +106,17 @@ const FileBrowser = (props: FileBrowserProps) => {
link.download = fileName; // Set the download attribute to specify the filename
// Append the anchor element to the document body
// Listen for the load event on the anchor element
link.onload = async () => {
// Make the data source private again after the download is done
privateFeed && (await makeDataSourcePrivate());
};

document.body.appendChild(link);
// Programmatically trigger the download
link.click();
// Remove the anchor element from the document body after the download is initiated
document.body.removeChild(link);

setTimeout(async () => {
privateFeed && (await makeDataSourcePrivate());
}, 2000); // Adjust the delay time as needed

return item;
} catch (e) {
throw e;
Expand Down

0 comments on commit ed090fa

Please sign in to comment.