Skip to content

Commit

Permalink
chore: Update environmentName in store schema and TopBar component
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Jun 3, 2024
1 parent 9f7aaf2 commit b9cbf28
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
3 changes: 1 addition & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ const createMainWindow = () => {
});

const storeInitialValues = {
appVersion: app.getVersion(),
releaseType: process.env.IS_STAGING ? 'draft' : 'release',
environmentName: process.env.IS_STAGING ? 'staging' : '',
};
setupStoreIpc(ipcMain, mainWindow, storeInitialValues);

Expand Down
3 changes: 1 addition & 2 deletions electron/store.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// set schema to validate store data
const defaultSchema = {
appVersion: { type: 'string', default: '' },
releaseType: { type: 'string', default: '' },
environmentName: { type: 'string', default: '' },
isInitialFunded: { type: 'boolean', default: false },
firstStakingRewardAchieved: { type: 'boolean', default: false },
firstRewardNotificationShown: { type: 'boolean', default: false },
Expand Down
15 changes: 2 additions & 13 deletions frontend/components/Layout/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Typography } from 'antd';
import { useMemo } from 'react';
import styled from 'styled-components';

import { COLOR } from '@/constants';
Expand Down Expand Up @@ -51,17 +50,7 @@ const TopBarContainer = styled.div`
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]);
const envName = store?.storeState?.environmentName;

return (
<TopBarContainer>
Expand All @@ -71,7 +60,7 @@ export const TopBar = () => {
<DisabledLight />
</TrafficLights>

<Text>{`Pearl (alpha) ${versionName}`.trim()}</Text>
<Text>{`Pearl (alpha) ${envName ? `(${envName})` : ''}`.trim()}</Text>
</TopBarContainer>
);
};
3 changes: 1 addition & 2 deletions frontend/types/ElectronApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type ElectronStore = {
appVersion?: string;
releaseType?: string;
environmentName?: string;
isInitialFunded?: boolean;
firstStakingRewardAchieved?: boolean;
firstRewardNotificationShown?: boolean;
Expand Down

0 comments on commit b9cbf28

Please sign in to comment.