Skip to content

Commit

Permalink
merge 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
thierryskoda committed Oct 17, 2024
2 parents 83cabe7 + eb9c49d commit f5ec44b
Show file tree
Hide file tree
Showing 14 changed files with 861 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- release/*
paths:
- "android/**"
- "package.json"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- release/*
paths:
- "ios/**"
- "package.json"
Expand Down
56 changes: 46 additions & 10 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,77 @@ on:
pull_request:
branches:
- main

- release/*
paths:
- "**/*.ts"
- "**/*.tsx"
- "package.json"
jobs:
tsc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4.0.2
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: "yarn"
- run: yarn
- run: yarn typecheck
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4.0.2
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: "yarn"
- run: yarn
- run: yarn lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4.0.2
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: "yarn"
- run: yarn
- run: yarn test
performance-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "yarn"
- run: |
BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}
# Required for `git switch` on CI
git fetch origin
# Gather baseline perf measurements
git switch "$BASELINE_BRANCH"
yarn
yarn reassure --baseline
# Gather current perf measurements & compare results
git switch --detach -
yarn
yarn reassure --branch
- name: Run Danger.js
run: yarn danger ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ builds

# iOS
ios/Converse.xcworkspace/xcshareddata/swiftpm/Package.resolved
# Reassure output directory
.reassure
6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"expo": {
"version": "2.0.6",
"version": "2.0.7",
"ios": {
"buildNumber": "2"
"buildNumber": "3"
},
"android": {
"versionCode": 208
"versionCode": 212
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { memo } from "react";

import { Optional } from "../../../types/general";
import {
IScreenHeaderIconButtonProps,

Check failure on line 5 in components/Screen/ScreenHeaderModalCloseButton/ScreenHeaderModalCloseButton.android.tsx

View workflow job for this annotation

GitHub Actions / tsc

'"../ScreenHeaderIconButton/ScreenHeaderIconButton"' has no exported member named 'IScreenHeaderIconButtonProps'. Did you mean 'ScreenHeaderIconButton'?

Check failure on line 5 in components/Screen/ScreenHeaderModalCloseButton/ScreenHeaderModalCloseButton.android.tsx

View workflow job for this annotation

GitHub Actions / tsc

'"../ScreenHeaderIconButton/ScreenHeaderIconButton"' has no exported member named 'IScreenHeaderIconButtonProps'. Did you mean 'ScreenHeaderIconButton'?
ScreenHeaderIconButton,
} from "../ScreenHeaderIconButton/ScreenHeaderIconButton";

export type IScreenHeaderModalCloseButtonProps = Optional<
IScreenHeaderIconButtonProps,
"picto"
>;

export const ScreenHeaderModalCloseButton = memo(
function ScreenHeaderModalCloseButton(
props: Optional<IScreenHeaderModalCloseButtonProps, "variant" | "title">
) {
const { title, variant, ...rest } = props;
return <ScreenHeaderIconButton picto="chevron.left" {...rest} />;

Check failure on line 19 in components/Screen/ScreenHeaderModalCloseButton/ScreenHeaderModalCloseButton.android.tsx

View workflow job for this annotation

GitHub Actions / tsc

Property 'onPress' is missing in type '{ picto: "chevron.left"; }' but required in type '{ onPress: () => void; }'.

Check failure on line 19 in components/Screen/ScreenHeaderModalCloseButton/ScreenHeaderModalCloseButton.android.tsx

View workflow job for this annotation

GitHub Actions / tsc

Property 'onPress' is missing in type '{ picto: "chevron.left"; }' but required in type '{ onPress: () => void; }'.
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { memo } from "react";
import { Platform } from "react-native";

import { Optional } from "../../../types/general";
import { ScreenHeaderButton } from "../ScreenHeaderButton/ScreenHeaderButton";
import { IScreenHeaderButtonProps } from "../ScreenHeaderButton/ScreenHeaderButton.props";

export type IScreenHeaderModalCloseButtonProps = Optional<
IScreenHeaderButtonProps,
"title"
>;

export const ScreenHeaderModalCloseButton = memo(
function ScreenHeaderModalCloseButton(
props: Optional<IScreenHeaderModalCloseButtonProps, "variant" | "title">
) {
const { title, variant, ...rest } = props;
return (
<ScreenHeaderButton
variant={variant ?? "text"}
title={
title ??
Platform.select({
android: "Back",
default: "Close",
})
}
{...rest}
/>
);
}
);
48 changes: 48 additions & 0 deletions components/__tests__/Avatar.perf-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { jest, test } from "@jest/globals";
import { screen } from "@testing-library/react-native";
import React from "react";
import { measureRenders } from "reassure";

import Avatar from "../Avatar";

jest.setTimeout(600_000);

const TestComponent = ({ uri }: { uri?: string }) => <Avatar uri={uri} />;

test("Empty Avatar 10 runs", async () => {
const scenario = async () => {
await screen.findByTestId("avatar-placeholder");
};

await measureRenders(<TestComponent />, { scenario, runs: 10 });
});

test("Empty Avatar 50 runs", async () => {
const scenario = async () => {
await screen.findByTestId("avatar-placeholder");
};

await measureRenders(<TestComponent />, { scenario, runs: 50 });
});

test("Avatar Image 10 runs", async () => {
const scenario = async () => {
await screen.findByTestId("avatar-image");
};

await measureRenders(<TestComponent uri="https://picsum.photos/200/300" />, {
scenario,
runs: 10,
});
});

test("Avatar Image 50 runs", async () => {
const scenario = async () => {
await screen.findByTestId("avatar-image");
};

await measureRenders(<TestComponent uri="https://picsum.photos/200/300" />, {
scenario,
runs: 50,
});
});
7 changes: 7 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import path from 'path';
import { dangerReassure } from 'reassure';

dangerReassure({
inputFilePath: path.join(__dirname, './.reassure/output.md'),
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"ios": "EXPO_ENV=dev expo start --ios",
"postinstall": "patch-package && node scripts/wasm.js && husky install && cross-os postinstall",
"start": "EXPO_ENV=dev expo start",
"test": "echo \"➜ Running tests...\" && jest",
"test": "echo \"➜ Running tests...\" && jest --testPathIgnorePatterns='.*\\.perf-test\\.tsx$'",
"test:perf": "echo \"➜ Running tests with performance...\" && echo \"➜ Capture baseline performance tests...\" && yarn reassure --baseline && echo \"➜ Running current performance tests...\" && jest --testPathIgnorePatterns='.*\\.perf-test\\.tsx$'",
"typecheck": "echo \"➜ Typechecking project...\" && tsc --noEmit",
"update": "node scripts/build/update.js",
"web:preview": "EXPO_ENV=preview expo export -p web"
Expand Down Expand Up @@ -219,6 +220,7 @@
"@typescript-eslint/typescript-estree": "^6.3.0",
"@welldone-software/why-did-you-render": "^8.0.3",
"cross-os": "^1.5.0",
"danger": "^12.3.3",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-universe": "^12.0.0",
Expand All @@ -238,6 +240,7 @@
"plist": "^3.0.6",
"prettier": "^3.0.1",
"process": "^0.11.10",
"reassure": "^1.2.1",
"sqlite3": "^5.1.4",
"ts-node": "^10.9.2",
"typescript": "^5.3.0",
Expand Down
19 changes: 19 additions & 0 deletions reassure-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e

BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}

# Required for `git switch` on CI
git fetch origin

# Gather baseline perf measurements
git switch "$BASELINE_BRANCH"

yarn
yarn reassure --baseline

# Gather current perf measurements & compare results
git switch --detach -

yarn
yarn reassure --branch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createNativeStackNavigator } from "@react-navigation/native-stack";
import * as Linking from "expo-linking";
import { Platform, useColorScheme } from "react-native";

import { SplitScreenDrawerParams } from "./SplitScreenNavigation";
import config from "../../../config";
import { useAppStore } from "../../../data/store/appStore";
import { isDesktop } from "../../../utils/device";
Expand All @@ -12,6 +11,7 @@ import ConversationNav, {
ConversationNavParams,
ConversationScreenConfig,
} from "../ConversationNav";
import GroupInviteNav from "../GroupInviteNav";
import GroupLinkNav, {
GroupLinkNavParams,
GroupLinkScreenConfig,
Expand All @@ -38,6 +38,7 @@ import {
getConverseStateFromPath,
stackGroupScreenOptions,
} from "../navHelpers";
import { SplitScreenDrawerParams } from "./SplitScreenNavigation";

export type NavigationParamList = {
Conversation: ConversationNavParams;
Expand Down Expand Up @@ -108,6 +109,7 @@ export default function SplitRightStackNavigation({
{GroupNav()}
{GroupLinkNav()}
{UserProfileNav()}
{GroupInviteNav()}
{TopUpNav()}
</NativeStack.Group>
</NativeStack.Navigator>
Expand Down
28 changes: 28 additions & 0 deletions utils/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,40 @@ const isDMLink = (url: string) => {
return false;
};

const isGroupInviteLink = (url: string) => {
for (const prefix of config.universalLinks) {
if (url.startsWith(prefix)) {
const path = url.slice(prefix.length);
if (path.toLowerCase().startsWith("group-invite/")) {
return true;
}
}
}
};

const isGroupLink = (url: string) => {
for (const prefix of config.universalLinks) {
if (url.startsWith(prefix)) {
const path = url.slice(prefix.length);
if (path.toLowerCase().startsWith("group/")) {
return true;
}
}
}
};

const originalOpenURL = RNLinking.openURL.bind(RNLinking);
RNLinking.openURL = (url: string) => {
// If the URL is a DM link, open it inside the app
// as a deeplink, not the browser
if (isDMLink(url)) {
return originalOpenURL(getSchemedURLFromUniversalURL(url));
}
if (isGroupInviteLink(url)) {
return originalOpenURL(getSchemedURLFromUniversalURL(url));
}
if (isGroupLink(url)) {
return originalOpenURL(getSchemedURLFromUniversalURL(url));
}
return originalOpenURL(url);
};
Loading

0 comments on commit f5ec44b

Please sign in to comment.