Skip to content

Commit

Permalink
feat(background): Adds logic to clean up storage after upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Sep 12, 2024
1 parent 5cc7cf4 commit 4c6abee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changes:
Fixes:
- Disables notifications in Safari due to API limitations ([391](https://github.com/freelawproject/recap-chrome/pull/391)).
- Fix fetch on firefox ([393](https://github.com/freelawproject/recap-chrome/pull/393)).
- Adds logic to clean up storage after uploads.

For developers:
- Preserves permissions during macOS and iOS release package creation ([391](https://github.com/freelawproject/recap-chrome/pull/391))
Expand Down
7 changes: 7 additions & 0 deletions src/utils/background_fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ async function triggerFetchRequest(url, options, sender, sendResponse) {
const blob = await fetch(file).then((res) => res.blob());
const body = buildFormData({ ...options.body, filepath_local: blob });
await waitUntil(dispatchCallback(url, { ...options, body }));

// Remove the 'pdf_blob' and 'zip_blob' properties from the specified key
// in Chrome's local storage after uploading their content.
if (store[storeKey]['pdf_blob']) delete store[storeKey]['pdf_blob'];
if (store[storeKey]['zip_blob']) delete store[storeKey]['zip_blob'];
await chrome.storage.local.set({ [storeKey]: store[storeKey] });
console.info('Temporary file data removed from storage.');
});
// return true to allow for the async function to complete
return true;
Expand Down

0 comments on commit 4c6abee

Please sign in to comment.