-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
src/providers/popup-context.tsx
Outdated
@@ -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' }) |
There was a problem hiding this comment.
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)
src/background/Background.ts
Outdated
] | ||
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Closes #58
Context