From fef8ac608d2ab86e35d878297836f2bb46882e32 Mon Sep 17 00:00:00 2001
From: Jed Fox <git@jedfox.com>
Date: Thu, 8 Sep 2022 08:59:24 -0400
Subject: [PATCH] =?UTF-8?q?Fix=20/schedule/discover=20behavior=20when=20it?=
 =?UTF-8?q?=E2=80=99s=20a=20page?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/schedules/DiscoverSchedules.js | 24 ++++++++++---------
 .../loot-design/src/components/sidebar.js     | 11 +++++----
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/packages/desktop-client/src/components/schedules/DiscoverSchedules.js b/packages/desktop-client/src/components/schedules/DiscoverSchedules.js
index f9fff59da..cd161bbda 100644
--- a/packages/desktop-client/src/components/schedules/DiscoverSchedules.js
+++ b/packages/desktop-client/src/components/schedules/DiscoverSchedules.js
@@ -26,13 +26,14 @@ import useSelected, {
 } from 'loot-design/src/components/useSelected';
 import { colors } from 'loot-design/src/style';
 
-import { Page } from '../Page';
+import { Page, usePageType } from '../Page';
 import DisplayId from '../util/DisplayId';
 import { ScheduleAmountCell } from './SchedulesTable';
 
 let ROW_HEIGHT = 43;
 
 function DiscoverSchedulesTable({ schedules, loading }) {
+  let pageType = usePageType();
   let selectedItems = useSelectedItems();
   let dispatchSelected = useSelectedDispatch();
 
@@ -100,9 +101,12 @@ function DiscoverSchedulesTable({ schedules, loading }) {
       </TableHeader>
       <Table
         rowHeight={ROW_HEIGHT}
-        backgroundColor="transparent"
         version="v2"
-        style={{ flex: 1, backgroundColor: 'transparent' }}
+        backgroundColor={pageType.type === 'modal' ? 'transparent' : undefined}
+        style={{
+          flex: 1,
+          backgroundColor: pageType.type === 'modal' ? 'transparent' : undefined
+        }}
         items={schedules}
         loading={loading}
         isSelected={id => selectedItems.has(id)}
@@ -114,7 +118,7 @@ function DiscoverSchedulesTable({ schedules, loading }) {
 }
 
 export default function DiscoverSchedules() {
-  let location = useLocation();
+  let pageType = usePageType();
   let history = useHistory();
   let [schedules, setSchedules] = useState();
   let [creating, setCreating] = useState(false);
@@ -174,11 +178,7 @@ export default function DiscoverSchedules() {
         on all transactions for a schedule to be the same payee.
       </P>
       <P>
-        You can always do this later
-        {Platform.isBrowser
-          ? ' from the "Find schedules" item in the sidebar menu'
-          : ' from the "Tools > Find schedules" menu item'}
-        .
+        You can always do this later from “More Tools” &rarr; “Find Schedules.”
       </P>
 
       <SelectedProvider instance={selectedInst}>
@@ -192,9 +192,11 @@ export default function DiscoverSchedules() {
         direction="row"
         align="center"
         justify="flex-end"
-        style={{ paddingTop: 20 }}
+        style={{
+          paddingTop: 20,
+          paddingBottom: pageType.type === 'modal' ? 0 : 20
+        }}
       >
-        <Button onClick={() => history.goBack()}>Do nothing</Button>
         <ButtonWithLoading
           primary
           loading={creating}
diff --git a/packages/loot-design/src/components/sidebar.js b/packages/loot-design/src/components/sidebar.js
index 627e81985..833c8944f 100644
--- a/packages/loot-design/src/components/sidebar.js
+++ b/packages/loot-design/src/components/sidebar.js
@@ -451,7 +451,7 @@ function Tools() {
           history.push('/rules');
           break;
         case 'find-schedules':
-          history.push('/schedule/discover', { locationPtr: history.location });
+          history.push('/schedule/discover');
           break;
         case 'repair-splits':
           history.push('/tools/fix-splits', { locationPtr: history.location });
@@ -472,9 +472,12 @@ function Tools() {
         onClick={onToggle}
         style={{ pointerEvents: isOpen ? 'none' : 'auto' }}
         forceHover={isOpen}
-        forceActive={['/payees', '/rules', '/tools'].some(route =>
-          location.pathname.startsWith(route)
-        )}
+        forceActive={[
+          '/payees',
+          '/rules',
+          '/tools',
+          '/schedule/discover'
+        ].some(route => location.pathname.startsWith(route))}
         button={
           <ChevronRight
             width={12}
-- 
GitLab