Skip to content

Commit

Permalink
Merge pull request #17 from Croustys/main
Browse files Browse the repository at this point in the history
changed localstorage to chrome storage
  • Loading branch information
nicosh authored Oct 1, 2021
2 parents c5801e0 + ef081c4 commit f2aa9ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/context/appContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SimpleMDE value={notes} onChange={onChange} />
Expand Down
1 change: 1 addition & 0 deletions src/components/misc/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const Github = () => {
}
if (n) {
localStorage.setItem('git_username', n)

} else {
localStorage.removeItem("git_username");
}
Expand Down

0 comments on commit f2aa9ba

Please sign in to comment.