ui: minor fixes

This commit is contained in:
thecodrr
2020-04-25 12:58:03 +05:00
parent 76df635dde
commit fc75aed605
4 changed files with 19 additions and 11 deletions

View File

@@ -12,6 +12,7 @@ import NavigationMenu from "./components/navigationmenu";
import NavigationContainer from "./navigation/container";
import RootNavigator from "./navigation/navigators/rootnavigator";
import EditorNavigator from "./navigation/navigators/editornavigator";
import { isMobile } from "./utils/dimensions";
function App() {
const [show, setShow] = usePersistentState("isContainerVisible", true);
@@ -39,11 +40,12 @@ function App() {
}, [openLastSession]);
useEffect(() => {
if (!isMobile()) return;
EditorNavigator.onNavigate = (route) => {
setShow(!!!route);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
},[]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<ThemeProvider>
@@ -70,7 +72,10 @@ function App() {
variant="columnFill"
/>
</Animated.Flex>
<Flex width={[show ? 0 : "100%", 0, "100%"]} className="EditorNavigator" />
<Flex
width={[show ? 0 : "100%", 0, "100%"]}
className="EditorNavigator"
/>
</Flex>
<Box id="dialogContainer" />
<Box id="snackbarContainer" />

View File

@@ -37,6 +37,7 @@ function Header() {
alignItems="center"
sx={{
paddingTop: [1, 2, 2],
paddingBottom: 0,
}}
>
<Icon.ChevronLeft

View File

@@ -3,9 +3,10 @@ import ReactDOM from "react-dom";
import Animated from "../components/animated";
import { AnimatePresence } from "framer-motion";
import { store as selectionStore } from "../stores/selection-store";
import {store as appStore} from "../stores/app-store";
import { store as appStore } from "../stores/app-store";
import Route from "./route";
import Config from "../utils/config";
import { isMobile } from "../utils/dimensions";
class Navigator {
constructor(root, routes, options = {}) {
@@ -48,7 +49,7 @@ class Navigator {
navigate(routeName, params = {}, force = false) {
let route = this.getRoute(routeName);
this.onNavigate(route);
if (!force && (!route || this.lastRoute === route)) {
@@ -71,7 +72,7 @@ class Navigator {
}
// exit selection mode on navigate
selectionStore.toggleSelectionMode(false);
ReactDOM.render(
<AnimatePresence exitBeforeEnter={true}>
<Animated.Flex
@@ -96,7 +97,7 @@ class Navigator {
</AnimatePresence>,
root
);
appStore.toggleSideMenu(false);
if (isMobile()) appStore.toggleSideMenu(false);
return true;
}

View File

@@ -37,13 +37,14 @@ class EditorStore extends BaseStore {
openLastSession = async () => {
// Do not reopen last session on mobile
if(isMobile()) return;
if (isMobile()) return;
const id = localStorage.getItem("lastOpenedNote");
if (!id) {
const note = db.notes.note(id);
if (!id || !note) {
return EditorNavigator.navigate("editor");
}
await this.openSession(db.notes.note(id).data);
await this.openSession(note.data);
};
openSession = async (note) => {