Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
benguedj committed Jul 31, 2023
2 parents 7fca96b + 861b9d7 commit 973b1f5
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 16 deletions.
17 changes: 14 additions & 3 deletions front/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Font from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { StatusBar } from "expo-status-bar";
import type { FC } from "react";
import * as React from "react";
Expand Down Expand Up @@ -30,6 +31,9 @@ import {
TrackerUtils,
} from "./src/utils";

// Keep the splash screen visible while we fetch resources
void SplashScreen.preventAutoHideAsync();

setNotificationHandler();
initLocales();
initMonitoring();
Expand Down Expand Up @@ -138,17 +142,24 @@ const MainAppContainer: FC = () => {

void init();
// Permet de détecter lorsque l'app change d'état ('active' | 'background' | 'inactive' | 'unknown' | 'extension')
AppState.addEventListener("change", handleAppStateChange);
const subscription = AppState.addEventListener(
"change",
handleAppStateChange
);

return () => {
AppState.removeEventListener("change", handleAppStateChange);
subscription.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (isLoadingComplete && fontsLoaded && appCounterIsLoaded) {
setScreenCanBeDisplayed(true);
const hideSplashScreen = async () => {
await SplashScreen.hideAsync();
setScreenCanBeDisplayed(true);
};
void hideSplashScreen();
}
}, [isLoadingComplete, fontsLoaded, appCounterIsLoaded]);

Expand Down
4 changes: 2 additions & 2 deletions front/app.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
const APP_VERSION = "1.1.88";
const APP_VERSION_NUM = 88;
const APP_VERSION = "1.1.92";
const APP_VERSION_NUM = 92;

export default {
expo: {
Expand Down
6 changes: 5 additions & 1 deletion front/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo", "@babel/preset-typescript"],
plugins: ["inline-dotenv", "react-native-reanimated/plugin"],
plugins: [
"inline-dotenv",
"react-native-reanimated/plugin",
["@babel/plugin-transform-private-methods", { loose: true }],
],
};
};
2 changes: 2 additions & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@react-navigation/bottom-tabs": "6.0.9",
"@react-navigation/native": "^6.0.6",
"@react-navigation/stack": "^6.0.11",
"@sentry/react-native": "4.15.2",
"@socialgouv/nos1000jours-lib": "1.2.1",
"babel-plugin-inline-dotenv": "^1.6.0",
"date-fns": "^2.25.0",
Expand Down Expand Up @@ -115,6 +116,7 @@
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/plugin-transform-private-methods": "^7.22.5",
"@babel/preset-typescript": "^7.16.0",
"@socialgouv/eslint-config-react": "^1.104.0",
"@socialgouv/eslint-config-typescript": "^1.88.0",
Expand Down
2 changes: 2 additions & 0 deletions front/src/components/app/checkAppVersion.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const CheckAppVersion: FC = () => {
fetchPolicy={FetchPoliciesConstants.NO_CACHE}
getFetchedData={handleResults}
showErrorMessage={false}
noLoader
noLoaderBackdrop
/>
);
};
Expand Down
2 changes: 2 additions & 0 deletions front/src/components/app/newFeatures.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const NewFeatures: React.FC = () => {
fetchPolicy={FetchPoliciesConstants.NO_CACHE}
getFetchedData={handleResults}
showErrorMessage={false}
noLoader
noLoaderBackdrop
/>
{html && (
<View style={styles.webviewContainer}>
Expand Down
16 changes: 14 additions & 2 deletions front/src/components/menu/infosDev.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Alert, ScrollView, StyleSheet, View } from "react-native";
import { Labels, StorageKeysConstants } from "../../constants";
import { Paddings, Styles } from "../../styles";
import type { RootStackParamList } from "../../types";
import { NotificationUtils, StorageUtils } from "../../utils";
import { NotificationUtils, reportError, StorageUtils } from "../../utils";
import { NotificationType } from "../../utils/notifications/notification.util";
import { getObjectValue } from "../../utils/storage.util";
import { CustomButton, SecondaryText } from "../baseComponents";
Expand All @@ -37,7 +37,7 @@ const InfosDev: FC<Props> = ({ navigation }) => {
const getAllScheduledNotifications = async () => {
const notifications =
await NotificationUtils.getAllScheduledNotifications();
if (notifications.length > 0) {
if (notifications !== undefined && notifications.length > 0) {
setNotificationsGroupByType(
_.groupBy(notifications, "content.data.type")
);
Expand Down Expand Up @@ -74,6 +74,10 @@ const InfosDev: FC<Props> = ({ navigation }) => {
Alert.alert(Labels.warning, Labels.infosDev.resetStorageDataAlertMsg);
}, []);

const sendFakeErrorInSentry = useCallback(() => {
reportError("Test - log fake error in Sentry");
}, []);

useEffect(() => {
void getAllScheduledNotifications();
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -166,6 +170,14 @@ const InfosDev: FC<Props> = ({ navigation }) => {
})}
</View>

<H2>{Labels.infosDev.sentry}</H2>
<CustomButton
title={Labels.infosDev.sentryLogError}
rounded={true}
buttonStyle={{ margin: Paddings.smaller }}
action={sendFakeErrorInSentry}
/>

{/* ENV */}
<H2>{Labels.infosDev.env}</H2>
<View>
Expand Down
2 changes: 2 additions & 0 deletions front/src/constants/Labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ export default {
resetStorageDataAlertMsg:
"Relancez l'app pour appliquer les modifications.",
scheduledNotifications: "Notifications programmées",
sentry: "Sentry",
sentryLogError: "Log in Sentry",
showStorageData: "Voir les données",
testNotification: "Tester une notification",
testNotificationInfo: `(se déclenche au bout de ${MIN_SECONDS}s)`,
Expand Down
4 changes: 0 additions & 4 deletions front/src/hooks/useCachedResources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Ionicons } from "@expo/vector-icons";
import * as Font from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { useEffect, useState } from "react";

const useCachedResources = (): boolean => {
Expand All @@ -10,8 +9,6 @@ const useCachedResources = (): boolean => {
useEffect(() => {
async function loadResourcesAndDataAsync() {
try {
void SplashScreen.preventAutoHideAsync();

// Load fonts
await Font.loadAsync({
...Ionicons.font,
Expand All @@ -34,7 +31,6 @@ const useCachedResources = (): boolean => {
console.warn(error);
} finally {
setLoadingComplete(true);
void SplashScreen.hideAsync();
}
}

Expand Down
48 changes: 44 additions & 4 deletions front/src/screens/search/tabSearchScreen.component.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Constants from "expo-constants";
import _ from "lodash";
import type { FC } from "react";
import { useCallback, useState } from "react";
import * as React from "react";
Expand All @@ -19,7 +21,12 @@ import {
PoisRoute,
} from "../../components/search/tabSearchRoutes.component";
import TrackerHandler from "../../components/tracker/trackerHandler.component";
import { FetchPoliciesConstants, Labels, SearchQueries } from "../../constants";
import {
FetchPoliciesConstants,
Labels,
SearchQueries,
StorageKeysConstants,
} from "../../constants";
import { GraphQLLazyQuery } from "../../services";
import {
Colors,
Expand All @@ -31,8 +38,14 @@ import {
Sizes,
} from "../../styles";
import type { TrackerSearch } from "../../type";
import type { Article } from "../../types";
import { KeyboardUtils, StringUtils, TrackerUtils } from "../../utils";
import type { TrackerUserInfo } from "../../type/userInfo.types";
import type { Article, UserSituation } from "../../types";
import {
KeyboardUtils,
StorageUtils,
StringUtils,
TrackerUtils,
} from "../../utils";

const TabSearchScreen: FC = () => {
const [keywords, setKeywords] = useState("");
Expand Down Expand Up @@ -71,8 +84,34 @@ const TabSearchScreen: FC = () => {
}
}, [keywords, triggerGetArticles]);

const getUserInfo = async () => {
const userSituations = (await StorageUtils.getObjectValue(
StorageKeysConstants.userSituationsKey
)) as UserSituation[] | null;
const gender = await StorageUtils.getObjectValue(
StorageKeysConstants.userGenderKey
);
const currentStep = await StorageUtils.getObjectValue(
StorageKeysConstants.currentStep
);

let userSituationLabel = null;
if (userSituations) {
const userSituation = _.find(userSituations, { isChecked: true });
userSituationLabel = userSituation?.label ?? null;
}

const userInfo: TrackerUserInfo = {
dimension1: Constants.expoConfig?.version ?? "",
dimension2: userSituationLabel,
dimension3: gender?.label ?? null,
dimension4: currentStep?.nom ?? null,
};
return userInfo;
};

const handleResults = useCallback(
(data: unknown) => {
async (data: unknown) => {
if (data) {
const results = (data as { articles: Article[] }).articles;
setArticles(results);
Expand All @@ -81,6 +120,7 @@ const TabSearchScreen: FC = () => {
category: trackerSearchCategory,
count: results.length,
keyword: keywords,
userInfo: await getUserInfo(),
});
} else setUpdatedText(Labels.errorMsg);
},
Expand Down

0 comments on commit 973b1f5

Please sign in to comment.