Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed May 9, 2024
2 parents 535848c + 807c945 commit 03f51ea
Show file tree
Hide file tree
Showing 191 changed files with 4,524 additions and 1,498 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001047002
versionName "1.4.70-2"
versionCode 1001047200
versionName "1.4.72-0"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
23 changes: 23 additions & 0 deletions contributingGuides/TS_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- [1.20 Hooks instead of HOCs](#hooks-instead-of-hocs)
- [1.21 `compose` usage](#compose-usage)
- [1.22 Type imports](#type-imports)
- [1.23 Ref types](#ref-types)
- [Exception to Rules](#exception-to-rules)
- [Communication Items](#communication-items)
- [Migration Guidelines](#migration-guidelines)
Expand Down Expand Up @@ -640,6 +641,28 @@ type Foo = {
export someVariable
```
- [1.23](#ref-types) **Ref types**: Avoid using HTML elements while declaring refs. Please use React Native components where possible. React Native Web handles the references on its own. It also extends React Native components with [Interaction API](https://necolas.github.io/react-native-web/docs/interactions/) which should be used to handle Pointer and Mouse events. Exception of this rule is when we explicitly need to use functions available only in DOM and not in React Native, e.g. `getBoundingClientRect`. Then please declare ref type as `union` of React Native component and HTML element. When passing it to React Native component assert it as soon as possible using utility methods declared in `src/types/utils`.
Normal usage:
```tsx
const ref = useRef<View>();

<View ref={ref} onPointerDown={e => {#DO SOMETHING}}>
```
Exceptional usage where DOM methods are necessary:
```tsx
import viewRef from '@src/types/utils/viewRef';

const ref = useRef<View | HTMLDivElement>();

if (ref.current && 'getBoundingClientRect' in ref.current) {
ref.current.getBoundingClientRect();
}

<View ref={viewRef(ref)} onPointerDown={e => {#DO SOMETHING}}>
```
## Exception to Rules
Most of the rules are enforced in ESLint or checked by TypeScript. If you think your particular situation warrants an exception, post the context in the `#expensify-open-source` Slack channel with your message prefixed with `TS EXCEPTION:`. The internal engineer assigned to the PR should be the one that approves each exception, however all discussion regarding granting exceptions should happen in the public channel instead of the GitHub PR page so that the TS migration team can access them easily.
Expand Down
1 change: 1 addition & 0 deletions desktop/ELECTRON_EVENTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const ELECTRON_EVENTS = {
KEYBOARD_SHORTCUTS_PAGE: 'keyboard-shortcuts-page',
START_UPDATE: 'start-update',
UPDATE_DOWNLOADED: 'update-downloaded',
SILENT_UPDATE: 'silent-update',
} as const;

export default ELECTRON_EVENTS;
1 change: 1 addition & 0 deletions desktop/contextBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const WHITELIST_CHANNELS_RENDERER_TO_MAIN = [
ELECTRON_EVENTS.REQUEST_VISIBILITY,
ELECTRON_EVENTS.START_UPDATE,
ELECTRON_EVENTS.LOCALE_UPDATED,
ELECTRON_EVENTS.SILENT_UPDATE,
] as const;

const WHITELIST_CHANNELS_MAIN_TO_RENDERER = [ELECTRON_EVENTS.KEYBOARD_SHORTCUTS_PAGE, ELECTRON_EVENTS.UPDATE_DOWNLOADED, ELECTRON_EVENTS.FOCUS, ELECTRON_EVENTS.BLUR] as const;
Expand Down
36 changes: 27 additions & 9 deletions desktop/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ process.argv.forEach((arg) => {
// happens correctly.
let hasUpdate = false;
let downloadedVersion: string;
let isSilentUpdating = false;

// Note that we have to subscribe to this separately and cannot use Localize.translateLocal,
// because the only way code can be shared between the main and renderer processes at runtime is via the context bridge
Expand All @@ -127,16 +128,20 @@ const quitAndInstallWithUpdate = () => {
autoUpdater.quitAndInstall();
};

/** Menu Item callback to triggers an update check */
const manuallyCheckForUpdates = (menuItem: MenuItem, browserWindow?: BrowserWindow) => {
// Disable item until the check (and download) is complete
// eslint: menu item flags like enabled or visible can be dynamically toggled by mutating the object
// eslint-disable-next-line no-param-reassign
menuItem.enabled = false;
/** Menu Item callback to trigger an update check */
const manuallyCheckForUpdates = (menuItem?: MenuItem, browserWindow?: BrowserWindow) => {
if (menuItem) {
// Disable item until the check (and download) is complete
// eslint-disable-next-line no-param-reassign -- menu item flags like enabled or visible can be dynamically toggled by mutating the object
menuItem.enabled = false;
}

autoUpdater
.checkForUpdates()
.catch((error) => ({error}))
.catch((error) => {
isSilentUpdating = false;
return {error};
})
.then((result) => {
const downloadPromise = result && 'downloadPromise' in result ? result.downloadPromise : undefined;

Expand All @@ -148,7 +153,7 @@ const manuallyCheckForUpdates = (menuItem: MenuItem, browserWindow?: BrowserWind
dialog.showMessageBox(browserWindow, {
type: 'info',
message: Localize.translate(preferredLocale, 'checkForUpdatesModal.available.title'),
detail: Localize.translate(preferredLocale, 'checkForUpdatesModal.available.message'),
detail: Localize.translate(preferredLocale, 'checkForUpdatesModal.available.message', {isSilentUpdating}),
buttons: [Localize.translate(preferredLocale, 'checkForUpdatesModal.available.soundsGood')],
});
} else if (result && 'error' in result && result.error) {
Expand All @@ -172,6 +177,10 @@ const manuallyCheckForUpdates = (menuItem: MenuItem, browserWindow?: BrowserWind
return downloadPromise;
})
.finally(() => {
isSilentUpdating = false;
if (!menuItem) {
return;
}
// eslint-disable-next-line no-param-reassign
menuItem.enabled = true;
});
Expand Down Expand Up @@ -201,7 +210,7 @@ const electronUpdater = (browserWindow: BrowserWindow): PlatformSpecificUpdater
if (checkForUpdatesMenuItem) {
checkForUpdatesMenuItem.visible = false;
}
if (browserWindow.isVisible()) {
if (browserWindow.isVisible() && !isSilentUpdating) {
browserWindow.webContents.send(ELECTRON_EVENTS.UPDATE_DOWNLOADED, info.version);
} else {
quitAndInstallWithUpdate();
Expand Down Expand Up @@ -604,6 +613,15 @@ const mainWindow = (): Promise<void> => {
}
});

// Automatically check for and install the latest version in the background
ipcMain.on(ELECTRON_EVENTS.SILENT_UPDATE, () => {
if (isSilentUpdating) {
return;
}
isSilentUpdating = true;
manuallyCheckForUpdates(undefined, browserWindow);
});

return browserWindow;
})

Expand Down
15 changes: 10 additions & 5 deletions docs/_data/_routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ platforms:
icon: /assets/images/hand-card.svg
description: Explore the perks and benefits of the Expensify Card.

- href: travel
title: Travel
icon: /assets/images/plane.svg
description: Manage all your corporate travel needs with Expensify Travel.

- href: copilots-and-delegates
title: Copilots & Delegates
icon: /assets/images/envelope-receipt.svg
Expand Down Expand Up @@ -114,16 +119,16 @@ platforms:
icon: /assets/images/money-into-wallet.svg
description: Learn more about expense tracking and submission.

- href: bank-accounts-and-payments
title: Bank Accounts & Payments
icon: /assets/images/bank-card.svg
description: Send direct reimbursements, pay invoices, and receive payment.

- href: expensify-card
title: Expensify Card
icon: /assets/images/hand-card.svg
description: Explore the perks and benefits of the Expensify Card.

- href: travel
title: Travel
icon: /assets/images/plane.svg
description: Manage all your corporate travel needs with Expensify Travel.

- href: connections
title: Connections
icon: /assets/images/workflow.svg
Expand Down
6 changes: 6 additions & 0 deletions docs/articles/expensify-classic/travel/Coming-Soon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Coming soon
description: Coming soon
---

# Coming soon

This file was deleted.

Loading

0 comments on commit 03f51ea

Please sign in to comment.