From 92e40467cb053eee91b5e3a447b12caa170a1238 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 30 May 2024 22:43:42 +0530 Subject: [PATCH] chore: Update releaseType in publishOptions and store schema --- electron/constants/publishOptions.js | 3 +-- electron/store.js | 21 +++++---------------- frontend/components/Layout/TopBar.tsx | 21 +++++++++++++-------- frontend/types/ElectronApi.ts | 1 + 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/electron/constants/publishOptions.js b/electron/constants/publishOptions.js index 3c57fb66..196f5be0 100644 --- a/electron/constants/publishOptions.js +++ b/electron/constants/publishOptions.js @@ -5,8 +5,7 @@ const publishOptions = { token: process.env.GH_TOKEN, private: false, publishAutoUpdate: true, - releaseType: process.env.IS_STAGING === 'true' ? 'prerelease' : 'release', - channel: process.env.IS_STAGING === 'true' ? 'alpha' : 'latest', + releaseType: process.env.IS_STAGING === 'true' ? 'draft' : 'release', }; module.exports = { publishOptions }; diff --git a/electron/store.js b/electron/store.js index e9efd1ee..4b06cfff 100644 --- a/electron/store.js +++ b/electron/store.js @@ -1,21 +1,10 @@ // set schema to validate store data const defaultSchema = { - appVersion: { - type: 'string', - default: '', - }, - isInitialFunded: { - type: 'boolean', - default: false, - }, - firstStakingRewardAchieved: { - type: 'boolean', - default: false, - }, - firstRewardNotificationShown: { - type: 'boolean', - default: false, - }, + appVersion: { type: 'string', default: '' }, + releaseType: { type: 'string', default: '' }, + isInitialFunded: { type: 'boolean', default: false }, + firstStakingRewardAchieved: { type: 'boolean', default: false }, + firstRewardNotificationShown: { type: 'boolean', default: false }, }; const setupStoreIpc = async (ipcChannel, mainWindow, storeInitialValues) => { diff --git a/frontend/components/Layout/TopBar.tsx b/frontend/components/Layout/TopBar.tsx index b16321cb..d9e7be9c 100644 --- a/frontend/components/Layout/TopBar.tsx +++ b/frontend/components/Layout/TopBar.tsx @@ -1,4 +1,5 @@ import { Typography } from 'antd'; +import { useMemo } from 'react'; import styled from 'styled-components'; import { COLOR } from '@/constants'; @@ -47,14 +48,21 @@ const TopBarContainer = styled.div` -webkit-app-region: drag; `; -const isStaging = (version?: string) => { - return !!version && (version.includes('alpha') || version.includes('beta')); -}; - export const TopBar = () => { const electronApi = useElectronApi(); const store = useStore(); + const versionName = useMemo(() => { + const releaseType = store?.storeState?.releaseType; + if (releaseType === 'draft') return ' (staging)'; + + const appVersion = store?.storeState?.appVersion; + if (!appVersion) return ''; + if (appVersion.includes('alpha')) return ''; // TODO + if (appVersion.includes('beta')) return ''; // TODO + return ''; + }, [store?.storeState?.appVersion, store?.storeState?.releaseType]); + return ( @@ -63,10 +71,7 @@ export const TopBar = () => { - - Pearl (alpha) - {isStaging(store?.storeState?.appVersion) ? ' (staging)' : ''} - + {`Pearl (alpha) ${versionName}`.trim()} ); }; diff --git a/frontend/types/ElectronApi.ts b/frontend/types/ElectronApi.ts index 3a5df5c9..ab1937e9 100644 --- a/frontend/types/ElectronApi.ts +++ b/frontend/types/ElectronApi.ts @@ -1,5 +1,6 @@ export type ElectronStore = { appVersion?: string; + releaseType?: string; isInitialFunded?: boolean; firstStakingRewardAchieved?: boolean; firstRewardNotificationShown?: boolean;