Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add storage.clear #1368

Merged
merged 3 commits into from
Jan 27, 2025
Merged

Conversation

chengxilo
Copy link
Contributor

Though it is easy to call browser.storage.clear() to clear all the items, I guess it is needed to support clear in wxt storage. So I add this method.

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 8121c27
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/679491e23a2cb400080dfb5e
😎 Deploy Preview https://deploy-preview-1368--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@chengxilo chengxilo changed the title feature: add clear method and test for wxt storage. feat: add clear method and test for wxt storage. Jan 24, 2025
@Timeraa
Copy link
Contributor

Timeraa commented Jan 24, 2025

I don't quite see why the module would need it if you have browser.storage.<area>.clear() since wxt/storage just adds some niche features on top of it

@chengxilo
Copy link
Contributor Author

I don't quite see why the module would need it if you have browser.storage.<area>.clear() since wxt/storage just adds some niche features on top of it

Yes, I agree that current approach of using browser.storage.<area>.clear() is enough.

However, I believe it would be much better if all my storage operations were handled uniformly through wxt-storage. At the moment, I use wxt-storage and directly call browser.storage..clear() because the method is not wrapped. But I wish I can handle all my storage operation in wxt-storage. In my opinion, consolidating all storage operations under a single abstraction layer would not only simplify the code but also provide a more consistent and pleasant development experience for developer using wxt.

But if wxt-storage is aimed to be a small package and only work for those complex method, I think clear can be ignored, as user can clean their storage easily with directly call and it should be enough.

Copy link
Collaborator

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, looks good. Some small changes and we can get this merged!

packages/storage/src/__tests__/index.test.ts Outdated Show resolved Hide resolved
packages/storage/src/index.ts Outdated Show resolved Hide resolved
@chengxilo chengxilo requested a review from aklinker1 January 25, 2025 07:36
Copy link

pkg-pr-new bot commented Jan 27, 2025

Open in Stackblitz

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@1368

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@1368

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@1368

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@1368

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@1368

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@1368

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@1368

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@1368

wxt

npm i https://pkg.pr.new/wxt@1368

commit: 8121c27

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.25%. Comparing base (a205f2a) to head (8121c27).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1368      +/-   ##
==========================================
- Coverage   81.34%   81.25%   -0.10%     
==========================================
  Files         128      128              
  Lines        6288     6288              
  Branches     1072     1071       -1     
==========================================
- Hits         5115     5109       -6     
- Misses       1158     1164       +6     
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aklinker1 aklinker1 changed the title feat: add clear method and test for wxt storage. feat: Add storage.clear Jan 27, 2025
@aklinker1 aklinker1 merged commit 20eea2a into wxt-dev:main Jan 27, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants