mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 12:41:45 +02:00
fix: auto delete empty note (#148)
This commit is contained in:
@@ -66,4 +66,4 @@
|
||||
"last 4 edge version"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,30 @@ import { Flex, Box } from "rebass";
|
||||
import ThemeProvider from "./components/theme-provider";
|
||||
import { usePersistentState } from "./utils/hooks";
|
||||
import { useStore } from "./stores/app-store";
|
||||
import { useStore as useAppStore } from "./stores/app-store";
|
||||
import { useStore as useEditorStore } from "./stores/editor-store";
|
||||
import { useStore as useUserStore } from "./stores/user-store";
|
||||
import { useStore as useNotesStore } from "./stores/note-store";
|
||||
import Animated from "./components/animated";
|
||||
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";
|
||||
import { db } from "./common";
|
||||
|
||||
function App() {
|
||||
const [show, setShow] = usePersistentState("isContainerVisible", true);
|
||||
const refreshColors = useStore((store) => store.refreshColors);
|
||||
const isFocusMode = useAppStore((store) => store.isFocusMode);
|
||||
const isFocusMode = useStore((store) => store.isFocusMode);
|
||||
const initUser = useUserStore((store) => store.init);
|
||||
const initNotes = useNotesStore((store) => store.init);
|
||||
const openLastSession = useEditorStore((store) => store.openLastSession);
|
||||
|
||||
useEffect(() => {
|
||||
refreshColors();
|
||||
initUser();
|
||||
}, [refreshColors, initUser]);
|
||||
initNotes();
|
||||
}, [refreshColors, initUser, initNotes]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isFocusMode) {
|
||||
@@ -47,6 +50,12 @@ function App() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
db.ev.unsubscribeAll();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<Flex id="app" bg="background" height="100%">
|
||||
|
||||
@@ -64,9 +64,8 @@ function Header() {
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
marginTop: dateEdited || text.length || id.length ? 0 : [0, 2, 2],
|
||||
marginBottom:
|
||||
dateEdited || text.length || id.length ? [1, 2, 2] : 0,
|
||||
marginTop: dateEdited || text?.length || id ? 0 : [0, 2, 2],
|
||||
marginBottom: dateEdited || text?.length || id ? [1, 2, 2] : 0,
|
||||
}}
|
||||
>
|
||||
{dateEdited > 0 ? (
|
||||
@@ -81,7 +80,7 @@ function Header() {
|
||||
<TextSeperator />
|
||||
</>
|
||||
) : null}
|
||||
{id && id.length > 0 ? <>{isSaving ? "Saving" : "Saved"}</> : null}
|
||||
{id ? <>{isSaving ? "Saving" : "Saved"}</> : null}
|
||||
</Text>
|
||||
</Flex>
|
||||
<Flex
|
||||
|
||||
@@ -286,7 +286,7 @@ class MarkdownShortcuts {
|
||||
if (!selection) return;
|
||||
const [line, offset] = this.quill.getLine(selection.index);
|
||||
const lineStart = selection.index - offset;
|
||||
const rawText = this.quill.getText(lineStart, selection.index - lineStart);
|
||||
//const rawText = this.quill.getText(lineStart, selection.index - lineStart);
|
||||
|
||||
// formulas count as a single character for insertion/deletion
|
||||
// purposes, yet they don't show up the output of getText.
|
||||
|
||||
@@ -13,6 +13,15 @@ class NoteStore extends BaseStore {
|
||||
context = undefined;
|
||||
selectedNote = 0;
|
||||
|
||||
init = () => {
|
||||
db.ev.subscribe("notes:removeEmptyNote", (id) => {
|
||||
const { session, newSession } = editorStore.get();
|
||||
if (session.id === id) {
|
||||
newSession();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
setSelectedNote = (id) => {
|
||||
this.set((state) => (state.selectedNote = id));
|
||||
};
|
||||
|
||||
@@ -7319,7 +7319,7 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
|
||||
|
||||
"notes-core@git+ssh://git@github.com:streetwriters/notesnook-core.git":
|
||||
version "1.5.0"
|
||||
resolved "git+ssh://git@github.com:streetwriters/notesnook-core.git#9e4abf6e98d98183bada040f9279989959f1bd14"
|
||||
resolved "git+ssh://git@github.com:streetwriters/notesnook-core.git#85b016c0756aaeeab9487de9068027edd40a075d"
|
||||
dependencies:
|
||||
crypto-random-string "^3.2.0"
|
||||
event-source-polyfill "^1.0.16"
|
||||
|
||||
Reference in New Issue
Block a user