Skip to content

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

fix: make mobile ui compatible with desktop

thecodrr205648e4f8dc
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index 902781272..f9f87297b 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -3,7 +3,6 @@ import StorageInterface from "../interfaces/storage";
import Database from "notes-core/api/";
import SelectionOptions from "./selectionoptions";
import EventSource from "eventsource";
-import { showTopicDialog } from "../components/dialogs/topicdialog";
import { showToast } from "../utils/toast";
import download from "../utils/download";
import { Text } from "rebass";
@@ -67,7 +66,10 @@ export const CREATE_BUTTON_MAP = {
title: "Create a notebook",
onClick: () => hashNavigate("/notebooks/create"),
},
- topics: { title: "Add a topic", onClick: showTopicDialog },
+ topics: {
+ title: "Add a topic",
+ onClick: () => hashNavigate(`/topics/create`),
+ },
};
export const DEFAULT_CONTEXT = { colors: [], tags: [], notebook: {} };
diff --git a/apps/web/src/components/dialogs/topicdialog.js b/apps/web/src/components/dialogs/topicdialog.js
index 25d57d4d3..652830268 100644
--- a/apps/web/src/components/dialogs/topicdialog.js
+++ b/apps/web/src/components/dialogs/topicdialog.js
@@ -57,7 +57,11 @@ export function showTopicDialog() {
));
}
-export function showEditTopicDialog(topic) {
+export function showEditTopicDialog(notebookId, topicId) {
+ const topic = db.notebooks.notebook(notebookId)?.topics?.topic(topicId)
+ ?._topic;
+ console.log(topic);
+ if (!topic) return;
return showDialog((perform) => (
<TopicDialog
title={"Edit Topic"}
diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.js
index a88d9f8bc..c31ae14ae 100644
--- a/apps/web/src/components/topic/index.js
+++ b/apps/web/src/components/topic/index.js
@@ -1,12 +1,12 @@
import React from "react";
import ListItem from "../list-item";
-import { showEditTopicDialog } from "../dialogs/topicdialog";
import { confirm } from "../dialogs/confirm";
import * as Icon from "../icons";
import { db } from "../../common";
import { store } from "../../stores/notebook-store";
import { store as appStore } from "../../stores/app-store";
import { Text } from "rebass";
+import { hashNavigate } from "../../navigation";
const menuItems = (item) => [
{
@@ -15,9 +15,8 @@ const menuItems = (item) => [
},
{
title: "Edit",
- onClick: () => {
- showEditTopicDialog(item);
- },
+ onClick: () =>
+ hashNavigate(`/notebooks/${item.notebookId}/topics/${item.id}/edit`),
visible: item.title !== "General",
},
{
diff --git a/apps/web/src/navigation/hash-routes.js b/apps/web/src/navigation/hash-routes.js
index db113c666..9b9b2cdba 100644
--- a/apps/web/src/navigation/hash-routes.js
+++ b/apps/web/src/navigation/hash-routes.js
@@ -15,6 +15,10 @@ import { store as appStore } from "../stores/app-store";
import { store as editorStore } from "../stores/editor-store";
import { store as noteStore } from "../stores/note-store";
import { isMobile, isTablet } from "../utils/dimensions";
+import {
+ showEditTopicDialog,
+ showTopicDialog,
+} from "../components/dialogs/topicdialog";
const hashroutes = {
"/": () => {
@@ -30,6 +34,12 @@ const hashroutes = {
"/notebooks/:notebookId/edit": ({ notebookId }) => {
showEditNotebookDialog(notebookId);
},
+ "/topics/create": () => {
+ showTopicDialog();
+ },
+ "/notebooks/:notebookId/topics/:topicId/edit": ({ notebookId, topicId }) => {
+ showEditTopicDialog(notebookId, topicId);
+ },
"/notes/create": () => {
console.log("session");
editorStore.get().newSession(noteStore.get().context);
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index 13c833d5f..a30ddae63 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -132,7 +132,6 @@ class EditorStore extends BaseStore {
};
newSession = (context = {}) => {
- appStore.setIsEditorOpen(true);
this.set((state) => {
state.session = {
...DEFAULT_SESSION,
@@ -141,6 +140,7 @@ class EditorStore extends BaseStore {
};
});
noteStore.setSelectedNote(0);
+ appStore.setIsEditorOpen(true);
};
clearSession = (shouldNavigate = true) => {
diff --git a/apps/web/src/views/home.js b/apps/web/src/views/home.js
index 12e224db2..2262e408b 100644
--- a/apps/web/src/views/home.js
+++ b/apps/web/src/views/home.js
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from "react";
import { useStore, store } from "../stores/note-store";
-import { useStore as useEditorStore } from "../stores/editor-store";
import ListContainer from "../components/list-container";
import NotesPlaceholder from "../components/placeholders/notesplacholder";
import { db } from "../common";
+import { hashNavigate } from "../navigation";
function Home() {
const [isLoading, setIsLoading] = useState(true);
@@ -26,7 +26,6 @@ function Home() {
})();
}, []);
const notes = useStore((store) => store.notes);
- const newSession = useEditorStore((store) => store.newSession);
return (
<ListContainer
@@ -34,7 +33,10 @@ function Home() {
isLoading={isLoading}
items={notes}
placeholder={NotesPlaceholder}
- button={{ content: "Make a new note", onClick: () => newSession() }}
+ button={{
+ content: "Make a new note",
+ onClick: () => hashNavigate("/notes/create"),
+ }}
/>
);
}
diff --git a/apps/web/src/views/notes.js b/apps/web/src/views/notes.js
index 2e2663466..790516c0a 100644
--- a/apps/web/src/views/notes.js
+++ b/apps/web/src/views/notes.js
@@ -1,13 +1,12 @@
import React, { useEffect, useState } from "react";
import ListContainer from "../components/list-container";
-import { useStore } from "../stores/editor-store";
import { useStore as useNotesStore } from "../stores/note-store";
import NotesPlaceholder from "../components/placeholders/notesplacholder";
import { db } from "../common";
+import { hashNavigate } from "../navigation";
function Notes(props) {
const [isLoading, setIsLoading] = useState(true);
- const newSession = useStore((store) => store.newSession);
const context = useNotesStore((store) => store.context);
const setContext = useNotesStore((store) => store.setContext);
@@ -32,7 +31,7 @@ function Notes(props) {
placeholder={props.placeholder || NotesPlaceholder}
button={{
content: "Make a new note",
- onClick: () => newSession(props.context),
+ onClick: () => hashNavigate("/notes/create"),
}}
/>
);
diff --git a/apps/web/src/views/topics.js b/apps/web/src/views/topics.js
index c2d271acb..3406d59d5 100644
--- a/apps/web/src/views/topics.js
+++ b/apps/web/src/views/topics.js
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import { Flex } from "rebass";
import ListContainer from "../components/list-container";
import { useStore as useNbStore } from "../stores/notebook-store";
-import { showTopicDialog } from "../components/dialogs/topicdialog";
+import { hashNavigate } from "../navigation";
function Topics(props) {
const { notebookId } = props;
@@ -32,9 +32,7 @@ function Topics(props) {
placeholder={Flex}
button={{
content: "Add a new topic",
- onClick: async () => {
- await showTopicDialog(notebookId);
- },
+ onClick: () => hashNavigate(`/topics/create`),
}}
/>
</>