Skip to content

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

mobile: fix note not added to default notebook in widget

Ammar Ahmed6e1739da2eff
diff --git a/apps/mobile/app/utils/note-bundle.js b/apps/mobile/app/utils/note-bundle.js
index d9e6f1a49..20b8ce414 100644
--- a/apps/mobile/app/utils/note-bundle.js
+++ b/apps/mobile/app/utils/note-bundle.js
@@ -66,17 +66,37 @@ async function createNotes(bundle) {
const sessionId = bundle.note.sessionId;
const id = await db.notes.add(bundle.note);
- for (const item of bundle.notebooks) {
- if (item.type === "notebook") {
- db.relations.add(item, { id, type: "note" });
- } else {
- db.notes.addToNotebook(
- {
- id: item.notebookId,
- topic: item.id
- },
- id
- );
+ if (!bundle.notebooks || !bundle.notebooks.length) {
+ const defaultNotebook = db.settings?.getDefaultNotebook();
+ if (defaultNotebook) {
+ if (!defaultNotebook.topic) {
+ db.relations.add(
+ { type: "notebook", id: defaultNotebook.id },
+ { id, type: "note" }
+ );
+ } else {
+ db.notes.addToNotebook(
+ {
+ id: defaultNotebook?.id,
+ topic: defaultNotebook.topic
+ },
+ id
+ );
+ }
+ }
+ } else {
+ for (const item of bundle.notebooks) {
+ if (item.type === "notebook") {
+ db.relations.add(item, { id, type: "note" });
+ } else {
+ db.notes.addToNotebook(
+ {
+ id: item.notebookId,
+ topic: item.id
+ },
+ id
+ );
+ }
}
}
diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js
index 2c814822d..97e5fd000 100644
--- a/apps/mobile/share/share.js
+++ b/apps/mobile/share/share.js
@@ -21,7 +21,7 @@ import ShareExtension from "@ammarahmed/react-native-share-extension";
import { getPreviewData } from "@flyerhq/react-native-link-preview";
import { formatBytes } from "@notesnook/common";
import { isImage } from "@notesnook/core/dist/utils/filename";
-import { parseHTML } from "@notesnook/core/dist/utils/html-parser";
+import { useThemeColors } from "@notesnook/theme";
import React, { useCallback, useEffect, useRef, useState } from "react";
import {
ActivityIndicator,
@@ -53,10 +53,9 @@ import { getElevationStyle } from "../app/utils/elevation";
import { eOnLoadNote } from "../app/utils/events";
import { NoteBundle } from "../app/utils/note-bundle";
import { Editor } from "./editor";
+import { HtmlLoadingWebViewAgent, fetchHandle } from "./fetch-webview";
import { Search } from "./search";
import { initDatabase, useShareStore } from "./store";
-import { useThemeColors } from "@notesnook/theme";
-import { HtmlLoadingWebViewAgent, fetchHandle } from "./fetch-webview";
const getLinkPreview = (url) => {
return getPreviewData(url, 5000);