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

refactor: use localstorage replace chrome storage #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KentonYu
Copy link
Contributor

@KentonYu KentonYu commented Sep 29, 2018

I use this extension by nginx inject js css,so can't use chrome's ability
use the localstorage replace the chrome's storage


@tomasbonco
Copy link
Owner

How do you use it? I guess you don't have either browser nor chrome object, right?

@KentonYu
Copy link
Contributor Author

yep,I use it by gitlab's nginx inject the js and css file link into gitlab mergerequest page's html file.
so no chrome extention's storage (browser/chrome object) .
I think that not only with the Chrome extention, also can link in html directly .

Object.keys(this.defaultValues).forEach((key) => {
const val = this.storage.getItem(key)
val && (result[key] = val)
})
Copy link
Contributor

@sumthief sumthief Oct 2, 2018

Choose a reason for hiding this comment

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

As you have no side effects you could use reduce here:

const result = Object.keys(this.defaultValues).reduce((prev, key) => {
   const val = this.storage.getItem(key);
   if (val) {
       prev[key] = val;
   }
   return prev;
}, { ...this.state });

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