mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
feat: create appstore
This commit is contained in:
@@ -71,12 +71,8 @@ function App() {
|
||||
0
|
||||
);
|
||||
const [show, setShow] = usePersistentState("navContainerState", true);
|
||||
const initStore = useStore(state => state.init);
|
||||
const isSideMenuOpen = useStore(state => state.isSideMenuOpen);
|
||||
useEffect(() => {
|
||||
initStore();
|
||||
}, [initStore]);
|
||||
|
||||
const isSideMenuOpen = useStore(state => state.isSideMenuOpen);
|
||||
useEffect(() => {
|
||||
RootNavigator.navigate(Object.keys(RootNavigator.routes)[selectedIndex]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as Icon from "react-feather";
|
||||
import ListItem from "../list-item";
|
||||
import { db, ev } from "../../common";
|
||||
import { showSnack } from "../snackbar";
|
||||
import { store } from "../../common/notebook-store";
|
||||
import { store } from "../../stores/notebook-store";
|
||||
|
||||
const dropdownRefs = [];
|
||||
const menuItems = (notebook, index) => [
|
||||
|
||||
18
apps/web/src/stores/app-store.js
Normal file
18
apps/web/src/stores/app-store.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { db } from "../common/index";
|
||||
import createStore from "../common/store";
|
||||
|
||||
function appStore(set) {
|
||||
return {
|
||||
isSideMenuOpen: false,
|
||||
closeSideMenu: function() {
|
||||
set(state => (state.isSideMenuOpen = false));
|
||||
},
|
||||
openSideMenu: function() {
|
||||
set(state => (state.isSideMenuOpen = true));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const [useStore, store] = createStore(appStore);
|
||||
|
||||
export { useStore, store };
|
||||
@@ -1,5 +1,5 @@
|
||||
import { db } from "./index";
|
||||
import createStore from "./store";
|
||||
import { db } from "../common/index";
|
||||
import createStore from "../common/store";
|
||||
|
||||
function notebookStore(set) {
|
||||
return {
|
||||
@@ -4,7 +4,7 @@ import { db } from "../common";
|
||||
import Notebook from "../components/notebook";
|
||||
import AddNotebookDialog from "../components/dialogs/addnotebookdialog";
|
||||
import ListContainer from "../components/list-container";
|
||||
import { useStore, store } from "../common/notebook-store";
|
||||
import { useStore, store } from "../stores/notebook-store";
|
||||
|
||||
const Notebooks = props => {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user