From 416c62369c9e72e822da85fe00c8dce8d566caa0 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 17 Oct 2025 12:41:39 +0200 Subject: [PATCH] refactor: extract VersionFooter component to eliminate duplication between debug and settings --- src/components/Debug.tsx | 25 ++----------------------- src/components/Settings.tsx | 26 ++------------------------ src/components/VersionFooter.tsx | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 47 deletions(-) create mode 100644 src/components/VersionFooter.tsx diff --git a/src/components/Debug.tsx b/src/components/Debug.tsx index 913a991d..2d0caab6 100644 --- a/src/components/Debug.tsx +++ b/src/components/Debug.tsx @@ -7,6 +7,7 @@ import { Accounts } from 'applesauce-accounts' import { NostrConnectSigner } from 'applesauce-signers' import { getDefaultBunkerPermissions } from '../services/nostrConnect' import { DebugBus, type DebugLogEntry } from '../utils/debugBus' +import VersionFooter from './VersionFooter' const defaultPayload = 'The quick brown fox jumps over the lazy dog.' @@ -351,29 +352,7 @@ const Debug: React.FC = () => { -
- - {typeof __RELEASE_URL__ !== 'undefined' && __RELEASE_URL__ ? ( - - Version {typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'} - - ) : ( - `Version ${typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'}` - )} - - {typeof __GIT_COMMIT__ !== 'undefined' && __GIT_COMMIT__ ? ( - - {' '}·{' '} - {typeof __GIT_COMMIT_URL__ !== 'undefined' && __GIT_COMMIT_URL__ ? ( - - {__GIT_COMMIT__.slice(0, 7)} - - ) : ( - {__GIT_COMMIT__.slice(0, 7)} - )} - - ) : null} -
+ ) } diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index b0ea0cc4..653697a5 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -1,4 +1,3 @@ -/* global __APP_VERSION__, __GIT_COMMIT__, __GIT_COMMIT_URL__, __RELEASE_URL__ */ import React, { useState, useEffect, useRef } from 'react' import { faTimes, faUndo } from '@fortawesome/free-solid-svg-icons' import { RelayPool } from 'applesauce-relay' @@ -12,6 +11,7 @@ import ZapSettings from './Settings/ZapSettings' import RelaySettings from './Settings/RelaySettings' import PWASettings from './Settings/PWASettings' import { useRelayStatus } from '../hooks/useRelayStatus' +import VersionFooter from './VersionFooter' const DEFAULT_SETTINGS: UserSettings = { collapseOnArticleOpen: true, @@ -168,29 +168,7 @@ const Settings: React.FC = ({ settings, onSave, onClose, relayPoo -
- - {typeof __RELEASE_URL__ !== 'undefined' && __RELEASE_URL__ ? ( - - Version {typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'} - - ) : ( - `Version ${typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'}` - )} - - {typeof __GIT_COMMIT__ !== 'undefined' && __GIT_COMMIT__ ? ( - - {' '}·{' '} - {typeof __GIT_COMMIT_URL__ !== 'undefined' && __GIT_COMMIT_URL__ ? ( - - {__GIT_COMMIT__.slice(0, 7)} - - ) : ( - {__GIT_COMMIT__.slice(0, 7)} - )} - - ) : null} -
+ ) } diff --git a/src/components/VersionFooter.tsx b/src/components/VersionFooter.tsx new file mode 100644 index 00000000..4ce1d587 --- /dev/null +++ b/src/components/VersionFooter.tsx @@ -0,0 +1,32 @@ +/* global __APP_VERSION__, __GIT_COMMIT__, __GIT_COMMIT_URL__, __RELEASE_URL__ */ +import React from 'react' + +const VersionFooter: React.FC = () => { + return ( +
+ + {typeof __RELEASE_URL__ !== 'undefined' && __RELEASE_URL__ ? ( + + Version {typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'} + + ) : ( + `Version ${typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev'}` + )} + + {typeof __GIT_COMMIT__ !== 'undefined' && __GIT_COMMIT__ ? ( + + {' '}·{' '} + {typeof __GIT_COMMIT_URL__ !== 'undefined' && __GIT_COMMIT_URL__ ? ( + + {__GIT_COMMIT__.slice(0, 7)} + + ) : ( + {__GIT_COMMIT__.slice(0, 7)} + )} + + ) : null} +
+ ) +} + +export default VersionFooter