Skip to content

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

mobile: update pinned notes widget on trash and restore

kashaf-ansari-dev7d68b4cca9c6
diff --git a/apps/mobile/app/components/note-history/preview.tsx b/apps/mobile/app/components/note-history/preview.tsx
index b2a7f4510..8c44ce097 100644
--- a/apps/mobile/app/components/note-history/preview.tsx
+++ b/apps/mobile/app/components/note-history/preview.tsx
@@ -28,6 +28,7 @@ import { ToastManager, eSendEvent } from "../../services/event-manager";
import Navigation from "../../services/navigation";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useTrashStore } from "../../stores/use-trash-store";
+import { PinnedNotesWidget } from "../../services/pinned-notes-widget";
import { eCloseSheet, eOnLoadNote } from "../../utils/events";
import { Dialog } from "../dialog";
import DialogHeader from "../dialog/dialog-header";
@@ -74,6 +75,7 @@ export default function NotePreview({
if (note && note.type === "trash") {
await db.trash.restore(note.id);
Navigation.queueRoutesForUpdate();
+ PinnedNotesWidget.updateNotes();
useSelectionStore.getState().setSelectionMode();
ToastManager.show({
heading: strings.noteRestored(),
diff --git a/apps/mobile/app/components/selection-header/index.tsx b/apps/mobile/app/components/selection-header/index.tsx
index 7614fcb34..a3a33fc3e 100644
--- a/apps/mobile/app/components/selection-header/index.tsx
+++ b/apps/mobile/app/components/selection-header/index.tsx
@@ -35,6 +35,7 @@ import useNavigationStore from "../../stores/use-navigation-store";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useTrashStore } from "../../stores/use-trash-store";
import { deleteItems } from "../../utils/functions";
+import { PinnedNotesWidget } from "../../services/pinned-notes-widget";
import { fluidTabsRef } from "../../utils/global-refs";
import { updateNotebook } from "../../utils/notebooks";
import { AppFontSize } from "../../utils/size";
@@ -87,6 +88,7 @@ export const SelectionHeader = React.memo(
if (!selectedItemsList.length) return;
await db.trash.restore(...selectedItemsList);
Navigation.queueRoutesForUpdate();
+ PinnedNotesWidget.updateNotes();
clearSelection();
ToastManager.show({
diff --git a/apps/mobile/app/hooks/use-actions.tsx b/apps/mobile/app/hooks/use-actions.tsx
index e26a38f5c..5d1f24432 100644
--- a/apps/mobile/app/hooks/use-actions.tsx
+++ b/apps/mobile/app/hooks/use-actions.tsx
@@ -279,6 +279,7 @@ export const useActions = ({
close();
await db.trash.restore(item.id);
Navigation.queueRoutesForUpdate();
+ PinnedNotesWidget.updateNotes();
const type = item.type === "trash" ? item.itemType : item.type;
ToastManager.show({
heading:
diff --git a/apps/mobile/app/utils/functions.ts b/apps/mobile/app/utils/functions.ts
index 64de8d014..fe61b4811 100644
--- a/apps/mobile/app/utils/functions.ts
+++ b/apps/mobile/app/utils/functions.ts
@@ -35,6 +35,7 @@ import { useTagStore } from "../stores/use-tag-store";
import { eUpdateNoteInEditor } from "./events";
import { unlockVault } from "./unlock-vault";
import { useTrashStore } from "../stores/use-trash-store";
+import { PinnedNotesWidget } from "../services/pinned-notes-widget";
export const valueLimiter = (value: number, min: number, max: number) => {
return value < min ? min : value > max ? max : value;
@@ -90,6 +91,7 @@ async function deleteNotebook(id: string, deleteNotes: boolean) {
await db.notes.moveToTrash(
...noteRelations.map((relation) => relation.toId)
);
+ PinnedNotesWidget.updateNotes();
}
}
await db.notebooks.moveToTrash(id);
@@ -151,6 +153,7 @@ export const deleteItems = async (
true
);
}
+ PinnedNotesWidget.updateNotes();
} else if (type === "notebook") {
const result = await confirmDeleteAllNotes(itemIds, "notebook", context);
if (!result.delete) return;
@@ -192,6 +195,7 @@ export const deleteItems = async (
Navigation.queueRoutesForUpdate();
useMenuStore.getState().setMenuPins();
useMenuStore.getState().setColorNotes();
+ PinnedNotesWidget.updateNotes();
ToastManager.hide();
if (type === "notebook") {
useNotebookStore.getState().refresh();