Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: make show/hide properties persistent

thecodrr6f77b5354be3
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index c9ee86e1c..4fdb5a855 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -5,8 +5,18 @@ import { Input } from "@rebass/forms";
import CheckBox from "../checkbox";
import { PinIcon } from "../icons";
+const usePersistentState = (key, def) => {
+ const defState = JSON.parse(window.localStorage.getItem(key) || def);
+ const [k, setKey] = useState(defState);
+ const _setKey = s => {
+ setKey(s);
+ window.localStorage.setItem(key, s);
+ };
+ return [k, _setKey];
+};
+
const Properties = props => {
- const [visible, setVisible] = useState(false);
+ const [visible, setVisible] = usePersistentState("propertiesVisible", false);
return !visible ? (
<Flex
onClick={() => setVisible(true)}