diff --git a/src/components/context/appContext.js b/src/components/context/appContext.js index 0d7237d..897336d 100644 --- a/src/components/context/appContext.js +++ b/src/components/context/appContext.js @@ -4,7 +4,8 @@ import React, { useState, useContext, useEffect } from 'react' export const AppContext = React.createContext(null) export function AppProvider({ children, ...rest }) { - const currentTheme = localStorage.getItem("theme") || "light"; + let currentTheme = "light"; + chrome.storage.local.get('theme', (thm) => currentTheme = thm.theme); const [history,setHistory] = useState([]) const [theme,setTheme] = useState(currentTheme) @@ -22,7 +23,7 @@ export function AppProvider({ children, ...rest }) { let newTheme = theme === "light" ? "dark" : "light" document.body.classList.add(newTheme); document.body.classList.remove(theme); - localStorage.setItem('theme', newTheme); + chrome.storage.local.set({'theme': newTheme}); setTheme(newTheme) } diff --git a/src/components/editor.js b/src/components/editor.js index d232b1f..1fbf163 100644 --- a/src/components/editor.js +++ b/src/components/editor.js @@ -7,12 +7,13 @@ const Editor = ()=>{ const [notes, setNotes] = useState("") useEffect(()=>{ - let text = localStorage.getItem("notestext") || "Write something..."; + let text = "Write something..."; + chrome.storage.local.get('notestext', (res) => text = res.notestext || "Write something..."); setNotes(text) },[]) const onChange = (value) => { - localStorage.setItem('notestext', value); + chrome.storage.local.set({'notestext': value}); setNotes(value); }; return diff --git a/src/components/misc/github/index.js b/src/components/misc/github/index.js index 4009959..022bf0e 100644 --- a/src/components/misc/github/index.js +++ b/src/components/misc/github/index.js @@ -62,6 +62,7 @@ const Github = () => { } if (n) { localStorage.setItem('git_username', n) + } else { localStorage.removeItem("git_username"); }