From 77a670bbc3ab030ef4219ec6745cfa4e68bfb5d9 Mon Sep 17 00:00:00 2001
From: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>
Date: Mon, 15 Apr 2024 11:51:09 -0700
Subject: [PATCH] [Mobile] Scheduled transaction menu modal (#2608)

* Mobile scheduled transaction menu modal

* Release notes
---
 .../mobile/accounts/AccountTransactions.jsx   | 24 +++++++++++++++++--
 upcoming-release-notes/2608.md                |  6 +++++
 2 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 upcoming-release-notes/2608.md

diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
index cf9c1c2e2..01fc53bb4 100644
--- a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
+++ b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
@@ -11,6 +11,7 @@ import memoizeOne from 'memoize-one';
 import { useDebounceCallback } from 'usehooks-ts';
 
 import {
+  collapseModals,
   getPayees,
   markAccountRead,
   openAccountCloseModal,
@@ -182,6 +183,10 @@ function TransactionListWithPreviews({ account }) {
     updateQuery(query);
   }, [makeRootQuery, updateQuery]);
 
+  const refetchTransactions = () => {
+    paged.current?.run();
+  };
+
   useEffect(() => {
     const unlisten = listen('sync-event', ({ type, tables }) => {
       if (type === 'applied') {
@@ -190,7 +195,7 @@ function TransactionListWithPreviews({ account }) {
           tables.includes('category_mapping') ||
           tables.includes('payee_mapping')
         ) {
-          paged.current?.run();
+          refetchTransactions();
         }
 
         if (tables.includes('payees') || tables.includes('payee_mapping')) {
@@ -231,9 +236,24 @@ function TransactionListWithPreviews({ account }) {
   };
 
   const onSelectTransaction = transaction => {
-    // details of how the native app used to handle preview transactions here can be found at commit 05e58279
     if (!isPreviewId(transaction.id)) {
       navigate(`/transactions/${transaction.id}`);
+    } else {
+      dispatch(
+        pushModal('scheduled-transaction-menu', {
+          transactionId: transaction.id,
+          onPost: async transactionId => {
+            const parts = transactionId.split('/');
+            await send('schedule/post-transaction', { id: parts[1] });
+            dispatch(collapseModals('scheduled-transaction-menu'));
+          },
+          onSkip: async transactionId => {
+            const parts = transactionId.split('/');
+            await send('schedule/skip-next-date', { id: parts[1] });
+            dispatch(collapseModals('scheduled-transaction-menu'));
+          },
+        }),
+      );
     }
   };
 
diff --git a/upcoming-release-notes/2608.md b/upcoming-release-notes/2608.md
new file mode 100644
index 000000000..48a2e1b54
--- /dev/null
+++ b/upcoming-release-notes/2608.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [joel-jeremy]
+---
+
+Allow posting/skipping scheduled transactions in mobile view.
-- 
GitLab