Skip to content

Commit

Permalink
fix(mobile): received user in BottomsTabNavigator bb-622
Browse files Browse the repository at this point in the history
  • Loading branch information
Shcracoziabra committed Sep 28, 2024
1 parent a17e993 commit 030ab97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { BaseColor, BottomTabScreenName, DataStatus } from "~/libs/enums/enums";
import { useAppDispatch, useAppSelector, useEffect } from "~/libs/hooks/hooks";
import { type BottomTabNavigationParameterList } from "~/libs/types/types";
import { WheelStackNavigator } from "~/navigations/bottom-tabs-navigator/wheel/wheel";
import { type UserDto } from "~/packages/users/users";
import { Chat } from "~/screens/chat/chat";
import { Settings } from "~/screens/settings/settings";
import { Tasks } from "~/screens/tasks/tasks";
import { actions as appActions } from "~/slices/app/app";
import { actions as userActions } from "~/slices/users/users";

import { styles } from "./styles";

Expand All @@ -40,6 +42,7 @@ const screenOptions: BottomTabNavigationOptions = {
const BottomTabsNavigator: React.FC = () => {
const dispatch = useAppDispatch();
const dataStatus = useAppSelector(({ app }) => app.dataStatus);
const authenticatedUser = useAppSelector(({ auth }) => auth.user);
const initialNotificationId = useAppSelector(
({ app }) => app.initialNotificationId,
);
Expand All @@ -52,6 +55,12 @@ const BottomTabsNavigator: React.FC = () => {
void dispatch(appActions.updateInitialNotificationId());
}, [dispatch]);

useEffect(() => {
void dispatch(
userActions.getById({ id: (authenticatedUser as UserDto).id }),
);
}, [dispatch, authenticatedUser]);

if (isLoading) {
return null;
}
Expand Down
10 changes: 0 additions & 10 deletions apps/mobile/src/screens/tasks/tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ import {
useAppDispatch,
useAppSelector,
useCallback,
useEffect,
useFocusEffect,
useState,
} from "~/libs/hooks/hooks";
import { globalStyles } from "~/libs/styles/styles";
import { type ImageSourcePropType } from "~/libs/types/types";
import { type TaskDto } from "~/packages/tasks/tasks";
import { type UserDto } from "~/packages/users/users";
import { actions as taskActions } from "~/slices/task/task";
import { actions as userActions } from "~/slices/users/users";

import { EmptyTasksHeader } from "./libs/components/components";
import { TaskStatus, TaskTab } from "./libs/enums/enums";
Expand All @@ -34,7 +31,6 @@ import { styles } from "./styles";
const Tasks: React.FC = () => {
const dispatch = useAppDispatch();

const authenticatedUser = useAppSelector(({ auth }) => auth.user);
const { activeTasks, dataStatus, expiredTasks, pastTasks } = useAppSelector(
({ tasks }) => tasks,
);
Expand All @@ -44,12 +40,6 @@ const Tasks: React.FC = () => {
const hasExpiredTasks = expiredTasks.length > NumericalValue.ZERO;
const taskbarTasks = isCurrentMode ? activeTasks : pastTasks;

useEffect(() => {
void dispatch(
userActions.getById({ id: (authenticatedUser as UserDto).id }),
);
}, [dispatch, authenticatedUser]);

useFocusEffect(
useCallback(() => {
void dispatch(taskActions.getCurrentTasks());
Expand Down

0 comments on commit 030ab97

Please sign in to comment.