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 session storage access levels, live update across instances + TSDocs IntelliSense for guidance #308

Merged
merged 6 commits into from
Dec 11, 2023

Conversation

D1no
Copy link
Contributor

@D1no D1no commented Nov 30, 2023

Hi thank you for maintaining this boilerplate :)

Session Storage Area and Access Levels

I've noticed that StorageType.Session wasn't able to be fully utilized, since they need an extra access-level step in chrome to allow content scripts to also access that storage area. A functionality that is pretty important for background workers processing page content.

So I have added that functionality after noticing.

In-Code Guidance via TSDocs

Also, since the whole browser extension landscape is rather confusing for most people, I have added brief TSDocs to the createStorage interface and proximal types to provide in editor guidance:

Kapture 2023-11-30 at 09 39 39


Cross-Page Live Update

Originally I wanted to extend your creatStorage solution with an aditional liveUpdate flag to be able to keep its many instances (content, popup, side panel, etc) synchronized through properly invalidating the cache with onChanged listeners... but I ran out of time for now.

In its current form, the storage and hooks only get pulled once a page starts... kinda omitting the big advantage of using the storage for keeping state in sync. Like when you change the color of your theme, you probably want that to be applied everywhere directly and not have to open and close pages.

Maybe I can do that at another time. All the best from Berlin!

Note:

Heads up: I am not sure how serious the firefox support in a chrome extension boilerplate is, but session storage areas are very differently handled by firefox. See here: chrome.storage.session in firefox

@D1no D1no requested a review from Jonghakseo as a code owner November 30, 2023 09:02
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. We will check and reply to you as soon as possible.

@D1no
Copy link
Contributor Author

D1no commented Dec 2, 2023

Found some time 🐌🐌

Cross-Page Live Update

Live Update across all extension instances are now available, leading to the theme value to update in real-time.

Removed ts-ignore comments

Factored out your valueOrUpdate logic into an async function and added type guards to get rid of the ts-ignore escape hatches

Kapture 2023-12-02 at 06 06 04

@D1no D1no changed the title feat: add session storage access levels and guide people via TSDocs IntelliSense feat: add session storage access levels, live update across instances + TSDocs IntelliSense for guidance Dec 2, 2023
Copy link
Owner

@Jonghakseo Jonghakseo left a comment

Choose a reason for hiding this comment

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

OMG.... it's insane!

I really appreciate the kind help and contributions from the other side of the world.

src/shared/storages/base.ts Show resolved Hide resolved
@Jonghakseo
Copy link
Owner

@all-contributors please add @D1no for code

Copy link
Contributor

@Jonghakseo

I've put up a pull request to add @D1no! 🎉

@Jonghakseo Jonghakseo added the enhancement New feature or request label Dec 2, 2023
@D1no
Copy link
Contributor Author

D1no commented Dec 4, 2023

Thank you 🥰 feel free to ship it or let me k ow what I should change ❤️ love intercontinental collaboration

@Jonghakseo Jonghakseo enabled auto-merge (squash) December 11, 2023 02:21
@Jonghakseo Jonghakseo merged commit c580f70 into Jonghakseo:main Dec 11, 2023
4 checks passed
aspiers pushed a commit to rolod0x/rolod0x that referenced this pull request Jan 28, 2024
live update across instances + TSDocs IntelliSense for guidance

Cherry-picked from c580f70

Jonghakseo/chrome-extension-boilerplate-react-vite@c580f70

See Jonghakseo/chrome-extension-boilerplate-react-vite#308

Co-authored-by: JongHak Seo <[email protected]>
aspiers pushed a commit to rolod0x/rolod0x that referenced this pull request Jan 28, 2024
live update across instances + TSDocs IntelliSense for guidance

Cherry-picked from c580f70

Jonghakseo/chrome-extension-boilerplate-react-vite@c580f70

See Jonghakseo/chrome-extension-boilerplate-react-vite#308

Co-authored-by: JongHak Seo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants