From 764a20a36bbb12aabecde7456af84ec8f9e5ece6 Mon Sep 17 00:00:00 2001
From: Shazib Hussain <me@shazib.com>
Date: Sat, 17 Jun 2023 02:37:30 +0100
Subject: [PATCH] Removing unused functions (#1145)

Continuing on from #1139 this PR deletes all function that are not used
anywhere.

The next PR will include all the entire files that are unused & deleted.
---
 .../desktop-client/src/components/common.tsx  |  46 --------
 .../components/manager/subscribe/common.tsx   | 103 +-----------------
 .../src/components/reports/util.js            |   4 -
 .../src/components/schedules/StatusBadge.js   |   6 -
 packages/desktop-client/src/hooks/index.js    |  16 +--
 packages/desktop-client/src/style.tsx         |   2 -
 upcoming-release-notes/1145.md                |   6 +
 7 files changed, 8 insertions(+), 175 deletions(-)
 create mode 100644 upcoming-release-notes/1145.md

diff --git a/packages/desktop-client/src/components/common.tsx b/packages/desktop-client/src/components/common.tsx
index 9df6cd347..183994882 100644
--- a/packages/desktop-client/src/components/common.tsx
+++ b/packages/desktop-client/src/components/common.tsx
@@ -356,40 +356,6 @@ export function Search({
   );
 }
 
-type KeyboardButtonProps = ComponentProps<typeof Button> & {
-  highlighted?: boolean;
-};
-export function KeyboardButton({
-  highlighted,
-  children,
-  ...props
-}: KeyboardButtonProps) {
-  return (
-    <Button
-      {...props}
-      bare
-      style={[
-        {
-          backgroundColor: 'white',
-          shadowColor: colors.n3,
-          shadowOffset: { width: 0, height: 1 },
-          shadowRadius: 1,
-          shadowOpacity: 1,
-          elevation: 4,
-          borderWidth: 0,
-          paddingLeft: 17,
-          paddingRight: 17,
-        },
-        highlighted && { backgroundColor: colors.p6 },
-        props.style,
-      ]}
-      textStyle={[highlighted && { color: 'white' }]}
-    >
-      {children}
-    </Button>
-  );
-}
-
 type SelectProps = HTMLPropsWithStyle<HTMLSelectElement>;
 
 export const Select = forwardRef<HTMLSelectElement, SelectProps>(
@@ -696,16 +662,6 @@ export function P({ style, isLast, children, ...props }: PProps) {
   );
 }
 
-type StrongProps = HTMLPropsWithStyle<HTMLSpanElement>;
-
-export function Strong({ style, children, ...props }: StrongProps) {
-  return (
-    <span {...props} {...css(style, { fontWeight: 500 })}>
-      {children}
-    </span>
-  );
-}
-
 type InlineFieldProps = {
   label: ReactNode;
   labelWidth?: number;
@@ -859,7 +815,5 @@ export function Label({ title, style }: LabelProps) {
   );
 }
 
-export const NullComponent = () => null;
-
 export * from './tooltips';
 export { useTooltip } from './tooltips';
diff --git a/packages/desktop-client/src/components/manager/subscribe/common.tsx b/packages/desktop-client/src/components/manager/subscribe/common.tsx
index 9e0082fb7..73b2c58b0 100644
--- a/packages/desktop-client/src/components/manager/subscribe/common.tsx
+++ b/packages/desktop-client/src/components/manager/subscribe/common.tsx
@@ -3,16 +3,13 @@ import React, {
   forwardRef,
   useEffect,
   useState,
-  type ReactNode,
 } from 'react';
 import { useHistory, useLocation } from 'react-router-dom';
 
-import { type CSSProperties } from 'glamor';
-
 import { send } from 'loot-core/src/platform/client/fetch';
 
 import { colors, styles } from '../../../style';
-import { Text, Button, Input as BaseInput } from '../../common';
+import { Input as BaseInput } from '../../common';
 import { useSetServerURL } from '../../ServerContext';
 
 // There are two URLs that dance with each other: `/login` and
@@ -78,14 +75,6 @@ export function useBootstrapped() {
   return { checked };
 }
 
-export function getEmail(location) {
-  let m = location.search.match(/email=([^&]*)/);
-  if (!m) {
-    return '';
-  }
-  return decodeURIComponent(m[1]);
-}
-
 type TitleProps = {
   text: string;
 };
@@ -122,93 +111,3 @@ export const Input = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
     />
   );
 });
-
-type BareButtonProps = ComponentProps<typeof Button>;
-export const BareButton = forwardRef<HTMLButtonElement, BareButtonProps>(
-  (props, ref) => {
-    return (
-      <Button
-        ref={ref}
-        bare
-        {...props}
-        style={[
-          {
-            color: colors.p4,
-            fontSize: 15,
-            textDecoration: 'none',
-            padding: '5px 7px',
-            borderRadius: 4,
-            ':hover': {
-              backgroundColor: colors.n9,
-            },
-            ':active': {
-              backgroundColor: colors.n9,
-            },
-          },
-          props.style,
-        ]}
-      />
-    );
-  },
-);
-
-type ExternalLinkProps = ComponentProps<typeof BareButton>;
-export const ExternalLink = forwardRef<HTMLButtonElement, ExternalLinkProps>(
-  (props, ref) => {
-    let { href, ...linkProps } = props;
-    return (
-      <BareButton
-        // @ts-expect-error prop does not exist on Button
-        to="/"
-        {...linkProps}
-        onClick={e => {
-          e.preventDefault();
-          window.Actual.openURLInBrowser(href);
-        }}
-      />
-    );
-  },
-);
-
-type BackLinkProps = ComponentProps<typeof BareButton> & {
-  history;
-};
-export const BackLink = forwardRef<HTMLButtonElement, BackLinkProps>(
-  (props, ref) => {
-    return (
-      <BareButton
-        ref={ref}
-        // @ts-expect-error prop does not exist on Button
-        to="/"
-        onClick={e => {
-          e.preventDefault();
-          props.history.goBack();
-        }}
-      >
-        Back
-      </BareButton>
-    );
-  },
-);
-
-type ParagraphProps = {
-  style?: CSSProperties;
-  children: ReactNode;
-};
-export function Paragraph({ style, children }: ParagraphProps) {
-  return (
-    <Text
-      style={[
-        {
-          fontSize: 15,
-          color: colors.n2,
-          lineHeight: 1.5,
-          marginTop: 20,
-        },
-        style,
-      ]}
-    >
-      {children}
-    </Text>
-  );
-}
diff --git a/packages/desktop-client/src/components/reports/util.js b/packages/desktop-client/src/components/reports/util.js
index 9866fca32..9cd905366 100644
--- a/packages/desktop-client/src/components/reports/util.js
+++ b/packages/desktop-client/src/components/reports/util.js
@@ -8,10 +8,6 @@ export function fromDateReprToDay(date) {
   return date;
 }
 
-export function toDateRepr(str) {
-  return parseInt(str.replace(/-/g, ''), 10);
-}
-
 export async function runAll(queries, cb) {
   let data = await Promise.all(
     queries.map(q => {
diff --git a/packages/desktop-client/src/components/schedules/StatusBadge.js b/packages/desktop-client/src/components/schedules/StatusBadge.js
index ca8fbea12..99ebf9f7e 100644
--- a/packages/desktop-client/src/components/schedules/StatusBadge.js
+++ b/packages/desktop-client/src/components/schedules/StatusBadge.js
@@ -66,12 +66,6 @@ export function getStatusProps(status) {
   return { color, backgroundColor, Icon };
 }
 
-export function StatusIcon({ status }) {
-  let { color, Icon } = getStatusProps(status);
-
-  return <Icon style={{ width: 13, height: 13, color }} />;
-}
-
 export function StatusBadge({ status, style }) {
   let { color, backgroundColor, Icon } = getStatusProps(status);
   return (
diff --git a/packages/desktop-client/src/hooks/index.js b/packages/desktop-client/src/hooks/index.js
index 85bd3a7dc..8304c4bbf 100644
--- a/packages/desktop-client/src/hooks/index.js
+++ b/packages/desktop-client/src/hooks/index.js
@@ -1,21 +1,7 @@
-import { useEffect, useRef } from 'react';
+import { useEffect } from 'react';
 
 import { setThemeColor } from '../util/withThemeColor';
 
-export function useScrollFlasher() {
-  let scrollRef = useRef(null);
-
-  useEffect(() => {
-    setTimeout(() => {
-      if (scrollRef.current) {
-        scrollRef.current.flashScrollIndicators();
-      }
-    }, 1000);
-  }, []);
-
-  return scrollRef;
-}
-
 export function useSetThemeColor(color) {
   useEffect(() => {
     setThemeColor(color);
diff --git a/packages/desktop-client/src/style.tsx b/packages/desktop-client/src/style.tsx
index 84fa957e7..13dbcc255 100644
--- a/packages/desktop-client/src/style.tsx
+++ b/packages/desktop-client/src/style.tsx
@@ -2,8 +2,6 @@ import * as Platform from 'loot-core/src/client/platform';
 
 import tokens from './tokens';
 
-export const debug = { borderWidth: 1, borderColor: 'red' };
-
 export const colors = {
   y1: '#733309',
   y2: '#87540d',
diff --git a/upcoming-release-notes/1145.md b/upcoming-release-notes/1145.md
new file mode 100644
index 000000000..252ad367a
--- /dev/null
+++ b/upcoming-release-notes/1145.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [Shazib]
+---
+
+Remove unused functions from source
-- 
GitLab