Compare commits

..

No commits in common. "9e6fee467fddf642e6056e3ad13a657290c74867" and "c3304c6f06e3ed222b56a960a389e4bbd805676b" have entirely different histories.

6 changed files with 21 additions and 30 deletions

View file

@ -53,9 +53,9 @@ type StateType = {
export default class App extends React.Component<{}, StateType> { export default class App extends React.Component<{}, StateType> {
navigatorRef: { current: null | NavigationContainerRef }; navigatorRef: { current: null | NavigationContainerRef };
defaultHomeRoute: string | undefined; defaultHomeRoute: string | null;
defaultHomeData: { [key: string]: string } | undefined; defaultHomeData: { [key: string]: string };
urlHandler: URLHandler; urlHandler: URLHandler;
@ -67,8 +67,8 @@ export default class App extends React.Component<{}, StateType> {
}; };
initLocales(); initLocales();
this.navigatorRef = React.createRef(); this.navigatorRef = React.createRef();
this.defaultHomeRoute = undefined; this.defaultHomeRoute = null;
this.defaultHomeData = undefined; this.defaultHomeData = {};
this.urlHandler = new URLHandler(this.onInitialURLParsed, this.onDetectURL); this.urlHandler = new URLHandler(this.onInitialURLParsed, this.onDetectURL);
this.urlHandler.listen(); this.urlHandler.listen();
setSafeBounceHeight(Platform.OS === 'ios' ? 100 : 20); setSafeBounceHeight(Platform.OS === 'ios' ? 100 : 20);

View file

@ -313,25 +313,18 @@ function MainStackComponent(props: {
} }
type PropsType = { type PropsType = {
defaultHomeRoute?: string; defaultHomeRoute: string | null;
defaultHomeData?: { [key: string]: string }; defaultHomeData: { [key: string]: string };
}; };
function MainNavigator(props: PropsType) { export default function MainNavigator(props: PropsType) {
const { preferences } = usePreferences(); const { preferences } = usePreferences();
const showIntro = getPreferenceBool(PreferenceKeys.showIntro, preferences); const showIntro = getPreferenceBool(PreferenceKeys.showIntro, preferences);
const createTabNavigator = () => <TabNavigator {...props} />;
return ( return (
<MainStackComponent <MainStackComponent
showIntro={showIntro !== false} showIntro={showIntro !== false}
createTabNavigator={createTabNavigator} createTabNavigator={() => <TabNavigator {...props} />}
/> />
); );
} }
export default React.memo(
MainNavigator,
(pp: PropsType, np: PropsType) =>
pp.defaultHomeRoute === np.defaultHomeRoute &&
pp.defaultHomeData === np.defaultHomeData
);

View file

@ -136,8 +136,8 @@ function PlanningStackComponent() {
const HomeStack = createStackNavigator(); const HomeStack = createStackNavigator();
function HomeStackComponent( function HomeStackComponent(
initialRoute?: string, initialRoute: string | null,
defaultData?: { [key: string]: string } defaultData: { [key: string]: string }
) { ) {
let params; let params;
if (initialRoute) { if (initialRoute) {
@ -232,8 +232,8 @@ function PlanexStackComponent() {
const Tab = createBottomTabNavigator<TabStackParamsList>(); const Tab = createBottomTabNavigator<TabStackParamsList>();
type PropsType = { type PropsType = {
defaultHomeRoute?: string; defaultHomeRoute: string | null;
defaultHomeData?: { [key: string]: string }; defaultHomeData: { [key: string]: string };
}; };
const ICONS: { const ICONS: {
@ -264,7 +264,7 @@ const ICONS: {
}, },
}; };
function TabNavigator(props: PropsType) { export default function TabNavigator(props: PropsType) {
const { preferences } = usePreferences(); const { preferences } = usePreferences();
let defaultRoute = getPreferenceString( let defaultRoute = getPreferenceString(
PreferenceKeys.defaultStartScreen, PreferenceKeys.defaultStartScreen,
@ -324,13 +324,6 @@ function TabNavigator(props: PropsType) {
); );
} }
export default React.memo(
TabNavigator,
(pp: PropsType, np: PropsType) =>
pp.defaultHomeRoute === np.defaultHomeRoute &&
pp.defaultHomeData === np.defaultHomeData
);
export enum TabRoutes { export enum TabRoutes {
Services = 'services', Services = 'services',
Proxiwash = 'proxiwash', Proxiwash = 'proxiwash',

View file

@ -139,6 +139,9 @@ const generateNewsFeed = (rawFeed: RawNewsFeedType): Array<FeedItemType> => {
return finalFeed; return finalFeed;
}; };
/**
* Class defining the app's home screen
*/
function HomeScreen(props: Props) { function HomeScreen(props: Props) {
const theme = useTheme(); const theme = useTheme();
const navigation = useNavigation(); const navigation = useNavigation();

View file

@ -15,8 +15,8 @@ import { CustomDarkTheme, CustomWhiteTheme } from '../utils/Themes';
import { setupStatusBar } from '../utils/Utils'; import { setupStatusBar } from '../utils/Utils';
type Props = { type Props = {
defaultHomeRoute?: string; defaultHomeRoute: string | null;
defaultHomeData?: { [key: string]: string }; defaultHomeData: { [key: string]: string };
}; };
function MainApp(props: Props, ref?: Ref<NavigationContainerRef>) { function MainApp(props: Props, ref?: Ref<NavigationContainerRef>) {

View file

@ -76,6 +76,8 @@ export function retrievePreferences(
return new Promise((resolve: (preferences: PreferencesType) => void) => { return new Promise((resolve: (preferences: PreferencesType) => void) => {
AsyncStorage.multiGet(keys) AsyncStorage.multiGet(keys)
.then((result) => { .then((result) => {
console.log(result);
const preferences = { ...defaults }; const preferences = { ...defaults };
result.forEach((item) => { result.forEach((item) => {
let [key, value] = item; let [key, value] = item;