diff --git a/apps/mobile/app/components/container/index.tsx b/apps/mobile/app/components/container/index.tsx
index 9cf81ba8b..6b79d34e8 100644
--- a/apps/mobile/app/components/container/index.tsx
+++ b/apps/mobile/app/components/container/index.tsx
@@ -17,13 +17,24 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-import React, { PropsWithChildren } from "react";
-import { Platform, View, useWindowDimensions } from "react-native";
+import React, { PropsWithChildren, useEffect, useRef, useState } from "react";
+import { Dimensions, Platform, View, useWindowDimensions } from "react-native";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
+import useKeyboard from "../../hooks/use-keyboard";
export const Container = ({ children }: PropsWithChildren) => {
const insets = useGlobalSafeAreaInsets();
- const dimensions = useWindowDimensions();
+ const keyboard = useKeyboard();
+ const [height, setHeight] = useState(0);
+ const windowHeightRef = useRef(Dimensions.get("window").height);
+ const { height: windowHeight } = useWindowDimensions();
+
+ useEffect(() => {
+ if (windowHeight !== windowHeightRef.current) {
+ setHeight(0);
+ windowHeightRef.current = windowHeight;
+ }
+ }, [windowHeight]);
return (
{
overflow: "hidden",
paddingTop: Platform.OS === "android" ? 0 : insets.top,
paddingBottom: Platform.OS === "android" ? 0 : insets.bottom,
- height: dimensions.height,
+ height: height || "100%",
width: "100%"
}}
+ onLayout={(event) => {
+ if (!keyboard.keyboardShown) {
+ setHeight(event.nativeEvent.layout.height);
+ }
+ }}
>
{children}
diff --git a/apps/mobile/app/components/sheets/notebook-sheet/index.tsx b/apps/mobile/app/components/sheets/notebook-sheet/index.tsx
index 18607596d..dce9ad4e8 100644
--- a/apps/mobile/app/components/sheets/notebook-sheet/index.tsx
+++ b/apps/mobile/app/components/sheets/notebook-sheet/index.tsx
@@ -109,17 +109,6 @@ export const NotebookSheet = () => {
true
);
- const PLACEHOLDER_DATA = {
- heading: "Notebooks",
- paragraph: "You have not added any notebooks yet.",
- button: "Add a notebook",
- action: () => {
- if (!notebook) return;
- AddNotebookSheet.present(undefined, notebook);
- },
- loading: "Loading notebook topics"
- };
-
const renderNotebook = ({ index }: { item: boolean; index: number }) => (
{
if (ref.current?.isOpen()) {
ref.current?.snapToIndex(snapPoint);
} else {
- ref.current?.show(snapPoint);
+ setTimeout(() => {
+ ref.current?.show(snapPoint);
+ }, 150);
}
- console.log("NotebookSheet.useEffect.canShow", focusedRouteId);
+ console.log("NotebookSheet.useEffect.didShow", focusedRouteId);
setRoot(nextRoot);
onRequestUpdate();
});
diff --git a/apps/mobile/app/utils/functions.js b/apps/mobile/app/utils/functions.js
index bd496c20b..3dfc38c99 100644
--- a/apps/mobile/app/utils/functions.js
+++ b/apps/mobile/app/utils/functions.js
@@ -63,14 +63,12 @@ async function deleteNotebook(id, deleteNotes) {
if (deleteNotes) {
const noteRelations = await db.relations.from(notebook, "note").get();
if (noteRelations?.length) {
- await db.notes.delete(...noteRelations.map((relation) => relation.toId));
+ await db.notes.moveToTrash(
+ ...noteRelations.map((relation) => relation.toId)
+ );
}
}
- const subnotebooks = await db.relations.from(notebook, "notebook").get();
- for (const subnotebook of subnotebooks) {
- await deleteNotebook(subnotebook.toId, deleteNotes);
- }
- await db.notebooks.remove(id);
+ await db.notebooks.moveToTrash(id);
if (parentId) {
eSendEvent(eOnNotebookUpdated, parentId);
}
@@ -98,7 +96,6 @@ export const deleteItems = async (items, type, context) => {
eSendEvent(eClearEditor);
} else if (type === "notebook") {
const result = await confirmDeleteAllNotes(ids, "notebook", context);
- console.log(result);
if (!result.delete) return;
for (const id of ids) {
await deleteNotebook(id, result.deleteNotes);