Skip to content

Commit

Permalink
Merge branch 'master' into translate-deskto-pelectron
Browse files Browse the repository at this point in the history
  • Loading branch information
psybers authored Sep 19, 2024
2 parents 23a85b5 + b3669b3 commit 54cd752
Show file tree
Hide file tree
Showing 195 changed files with 4,721 additions and 4,733 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ packages/desktop-client/**/node_modules/*
packages/desktop-client/node_modules/
packages/desktop-client/src/icons/**/*
packages/desktop-client/test-results/
packages/desktop-client/playwright-report/

packages/desktop-electron/client-build/
packages/desktop-electron/dist/
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 3 additions & 7 deletions packages/desktop-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"devDependencies": {
"@juggle/resize-observer": "^3.4.0",
"@playwright/test": "1.41.1",
"@react-aria/focus": "^3.16.0",
"@react-aria/listbox": "^3.11.3",
"@react-aria/utils": "^3.23.0",
"@react-stately/collections": "^3.10.4",
"@react-stately/list": "^3.10.2",
"@rollup/plugin-inject": "^5.0.5",
"@svgr/cli": "^8.1.0",
"@swc/core": "^1.5.3",
Expand Down Expand Up @@ -54,8 +49,8 @@
"promise-retry": "^2.0.1",
"re-resizable": "^6.9.17",
"react": "18.2.0",
"react-aria": "^3.33.1",
"react-aria-components": "^1.2.1",
"react-aria": "^3.34.3",
"react-aria-components": "^1.3.3",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "18.2.0",
Expand All @@ -69,6 +64,7 @@
"react-router-dom": "6.21.3",
"react-simple-pull-to-refresh": "^1.3.3",
"react-spring": "^9.7.3",
"react-stately": "^3.10.9",
"react-virtualized-auto-sizer": "^1.0.21",
"recharts": "^2.10.4",
"redux": "^4.2.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ global.Actual = {
window.location.reload();
},

restartElectronServer: () => {},

openFileDialog: async ({ filters = [] }) => {
return new Promise(resolve => {
let createdElement = false;
Expand Down
120 changes: 60 additions & 60 deletions packages/desktop-client/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// @ts-strict-ignore
import React, { useEffect, useState } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import {
ErrorBoundary,
useErrorBoundary,
type FallbackProps,
} from 'react-error-boundary';
import { HotkeysProvider } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';

import {
closeBudget,
Expand All @@ -16,8 +19,8 @@ import {
setAppState,
sync,
} from 'loot-core/client/actions';
import { SpreadsheetProvider } from 'loot-core/client/SpreadsheetProvider';
import * as Platform from 'loot-core/src/client/platform';
import { type State } from 'loot-core/src/client/state-types';
import {
init as initConnection,
send,
Expand All @@ -27,25 +30,25 @@ import { useMetadataPref } from '../hooks/useMetadataPref';
import { installPolyfills } from '../polyfills';
import { ResponsiveProvider } from '../ResponsiveProvider';
import { styles, hasHiddenScrollbars, ThemeStyle } from '../style';
import { ExposeNavigate } from '../util/router-tools';

import { AppBackground } from './AppBackground';
import { BudgetMonthCountProvider } from './budget/BudgetMonthCountContext';
import { View } from './common/View';
import { DevelopmentTopBar } from './DevelopmentTopBar';
import { FatalError } from './FatalError';
import { FinancesApp } from './FinancesApp';
import { ManagementApp } from './manager/ManagementApp';
import { Modals } from './Modals';
import { ScrollProvider } from './ScrollProvider';
import { SidebarProvider } from './sidebar/SidebarProvider';
import { UpdateNotification } from './UpdateNotification';

type AppInnerProps = {
budgetId: string;
cloudFileId: string;
};

function AppInner({ budgetId, cloudFileId }: AppInnerProps) {
function AppInner() {
const [budgetId] = useMetadataPref('id');
const [cloudFileId] = useMetadataPref('cloudFileId');
const { t } = useTranslation();
const [initializing, setInitializing] = useState(true);
const { showBoundary: showErrorBoundary } = useErrorBoundary();
const loadingText = useSelector((state: State) => state.app.loadingText);
const dispatch = useDispatch();

async function init() {
Expand Down Expand Up @@ -74,9 +77,7 @@ function AppInner({ budgetId, cloudFileId }: AppInnerProps) {
);
const budgetId = await send('get-last-opened-backup');
if (budgetId) {
await dispatch(
loadBudget(budgetId, t('Loading the last budget file...')),
);
await dispatch(loadBudget(budgetId));

// Check to see if this file has been remotely deleted (but
// don't block on this in case they are offline or something)
Expand All @@ -99,12 +100,7 @@ function AppInner({ budgetId, cloudFileId }: AppInnerProps) {
useEffect(() => {
async function initAll() {
await Promise.all([installPolyfills(), init()]);
setInitializing(false);
dispatch(
setAppState({
loadingText: null,
}),
);
dispatch(setAppState({ loadingText: null }));
}

initAll().catch(showErrorBoundary);
Expand All @@ -114,21 +110,7 @@ function AppInner({ budgetId, cloudFileId }: AppInnerProps) {
global.Actual.updateAppMenu(budgetId);
}, [budgetId]);

return (
<>
{(initializing || !budgetId) && (
<AppBackground initializing={initializing} loadingText={loadingText} />
)}
{!initializing &&
(budgetId ? (
<FinancesApp />
) : (
<ManagementApp isLoading={loadingText != null} />
))}

<UpdateNotification />
</>
);
return budgetId ? <FinancesApp /> : <ManagementApp />;
}

function ErrorFallback({ error }: FallbackProps) {
Expand All @@ -141,8 +123,6 @@ function ErrorFallback({ error }: FallbackProps) {
}

export function App() {
const [budgetId] = useMetadataPref('id');
const [cloudFileId] = useMetadataPref('cloudFileId');
const [hiddenScrollbars, setHiddenScrollbars] = useState(
hasHiddenScrollbars(),
);
Expand Down Expand Up @@ -176,29 +156,49 @@ export function App() {
}, [dispatch]);

return (
<HotkeysProvider initiallyActiveScopes={['*']}>
<ResponsiveProvider>
<View
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
>
<View
key={hiddenScrollbars ? 'hidden-scrollbars' : 'scrollbars'}
style={{
flexGrow: 1,
overflow: 'hidden',
...styles.lightScrollbar,
}}
>
<ErrorBoundary FallbackComponent={ErrorFallback}>
{process.env.REACT_APP_REVIEW_ID && !Platform.isPlaywright && (
<DevelopmentTopBar />
)}
<AppInner budgetId={budgetId} cloudFileId={cloudFileId} />
</ErrorBoundary>
<ThemeStyle />
</View>
</View>
</ResponsiveProvider>
</HotkeysProvider>
<BrowserRouter>
<ExposeNavigate />
<HotkeysProvider initiallyActiveScopes={['*']}>
<ResponsiveProvider>
<SpreadsheetProvider>
<SidebarProvider>
<BudgetMonthCountProvider>
<DndProvider backend={HTML5Backend}>
<ScrollProvider>
<View
style={{
height: '100%',
display: 'flex',
flexDirection: 'column',
}}
>
<View
key={
hiddenScrollbars ? 'hidden-scrollbars' : 'scrollbars'
}
style={{
flexGrow: 1,
overflow: 'hidden',
...styles.lightScrollbar,
}}
>
<ErrorBoundary FallbackComponent={ErrorFallback}>
{process.env.REACT_APP_REVIEW_ID &&
!Platform.isPlaywright && <DevelopmentTopBar />}
<AppInner />
</ErrorBoundary>
<ThemeStyle />
<Modals />
<UpdateNotification />
</View>
</View>
</ScrollProvider>
</DndProvider>
</BudgetMonthCountProvider>
</SidebarProvider>
</SpreadsheetProvider>
</ResponsiveProvider>
</HotkeysProvider>
</BrowserRouter>
);
}
13 changes: 6 additions & 7 deletions packages/desktop-client/src/components/AppBackground.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { useTransition, animated } from 'react-spring';

import { css } from 'glamor';
Expand All @@ -11,14 +12,12 @@ import { Block } from './common/Block';
import { View } from './common/View';

type AppBackgroundProps = {
initializing?: boolean;
loadingText?: string;
isLoading?: boolean;
};

export function AppBackground({
initializing,
loadingText,
}: AppBackgroundProps) {
export function AppBackground({ isLoading }: AppBackgroundProps) {
const loadingText = useSelector(state => state.app.loadingText);
const showLoading = isLoading || loadingText !== null;
const transitions = useTransition(loadingText, {
from: { opacity: 0, transform: 'translateY(-100px)' },
enter: { opacity: 1, transform: 'translateY(0)' },
Expand All @@ -30,7 +29,7 @@ export function AppBackground({
<>
<Background />

{(loadingText != null || initializing) &&
{showLoading &&
transitions((style, item) => (
<animated.div key={item} style={style}>
<View
Expand Down
Loading

0 comments on commit 54cd752

Please sign in to comment.