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: extension background storage #98

Merged
merged 4 commits into from
Feb 19, 2024
Merged

feat: extension background storage #98

merged 4 commits into from
Feb 19, 2024

Conversation

ionutanin
Copy link
Contributor

Closes #58

Context

  • add background extension storage configuration
  • define storage keys
  • sync background storage with popup context

@ionutanin ionutanin added area: background Improvements or additions to extension background script area: popup Improvements or additions to extension popup labels Feb 13, 2024
@github-actions github-actions bot removed the area: popup Improvements or additions to extension popup label Feb 13, 2024
@ionutanin ionutanin changed the title feature: extension background storage feat: extension background storage Feb 13, 2024
@raducristianpopa
Copy link
Member

raducristianpopa commented Feb 13, 2024

Extension builds preview

Name Link
Latest commit 35a2183
Latest job logs Run #7961305465
BadgeDownload
BadgeDownload
BadgeDownload
BadgeDownload

@@ -27,6 +29,17 @@ export const PopupContext = createContext<PopupContextValue>({
export const PopupProvider: React.FC<IProps> = ({ children }) => {
const [data, setData] = useState<TPopupContext>(defaultData)

const getStorageData = async () => await sendMessage({ type: 'GET_STORAGE_DATA' })
Copy link
Contributor

@dianafulga dianafulga Feb 14, 2024

Choose a reason for hiding this comment

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

there are no dependencies, so it can be moved outside the component, maybe a utils file associated with the popup-context provider (maybe group under a folder)

]
private subscriptions: any = []
// TO DO: remove these from background into storage or state & use injection
grantFlow: PaymentFlowService | null = null
spentAmount: number = 0
paymentStarted = false

constructor() {}
constructor({ storageService }: any) {
storageService
Copy link
Contributor

Choose a reason for hiding this comment

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

initialisation of data should be done when create a new instance of storage, because it's a singleton

import Background from '@/background/Background'

const getStorageData = async (background: Background) => {
console.log('getStorageData background', background)
Copy link
Contributor

Choose a reason for hiding this comment

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

I get this is a dummy example, but to show case the usage, you can invoke the background.storageService and return the result

dianafulga
dianafulga previously approved these changes Feb 14, 2024
@github-actions github-actions bot added the area: popup Improvements or additions to extension popup label Feb 19, 2024
@ionutanin ionutanin merged commit b944898 into main Feb 19, 2024
9 checks passed
@ionutanin ionutanin deleted the ia--extension-storage branch February 19, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: background Improvements or additions to extension background script area: popup Improvements or additions to extension popup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure extension storage
3 participants