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 ability for background tasks and local storage #58

Merged
merged 3 commits into from
Mar 16, 2021

Conversation

LiuChangFreeman
Copy link
Contributor

@LiuChangFreeman LiuChangFreeman commented Mar 15, 2021

- compact source code files, all convert to typescript

Now all source codes are converted to typescript. We don't use .js for source code anymore.

- add chrome api for background tasks and local storage

Now in src/pages/Background/index.ts, we can do tasks which should be done every several minutes. Such as checking for updates or getting daily notice. In src/utils/utils.ts, I make a wrapper for chrome.storage.local.set()/get(), and we can store meta data in user's local storage by calling await easily. Here is an example:

export async function test(){
  const key="test",value=100;
  await chrome_set(key,value);
  const result=await chrome_get(key);
  console.log(result);
  // and you will get: {"test":100}
}

test();// call it somewhere else

@heming6666
Copy link
Contributor

Great job! Thanks @LiuChangFreeman .

/approve

@menbotics menbotics bot added the pull/approved If a pull is approved, it will be automatically merged label Mar 16, 2021
@menbotics menbotics bot merged commit e580f2f into hypertrons:master Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull/approved If a pull is approved, it will be automatically merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants