Skip to content

Commit

Permalink
Little cleanup 🧹
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-iaco committed Jan 21, 2023
1 parent 587a35b commit 81a36df
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 24 deletions.
8 changes: 0 additions & 8 deletions src/action/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const SET_CURRENT_MEAL_DATE_TYPE = "SET_CURRENT_MEAL_DATE";

export const SET_LANGUAGE_TYPE = "SET_LANGUAGE";

export const SET_IS_USER_PERSISTED_TYPE = "SET_IS_USER_PERSISTED";

export const setCurrentItem = (item?: Item): Action => {
return {
Expand Down Expand Up @@ -147,10 +146,3 @@ export const setLanguage = (language: string): Action => {
payload: language
};
}

export const setIsUserPersisted = (isUserPersisted: boolean): Action => {
return {
type: SET_IS_USER_PERSISTED_TYPE,
payload: isUserPersisted
};
}
3 changes: 1 addition & 2 deletions src/page/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
User as FirebaseUser,
} from "firebase/auth";
import {useDispatch} from "react-redux";
import {setError, setIsUserPersisted, setUser} from "../../action/Action";
import {setError, setUser} from "../../action/Action";
import {analytics, auth, mapFirebaseUserToUser} from "../../utils/firebaseUtils";
import {AppBarComponent} from "../../component/AppBarComponent";
import {strings} from "../../localization/strings";
Expand All @@ -43,7 +43,6 @@ const LoginPage = () => {
}

const login = () => {
dispatch(setIsUserPersisted(true));
setPersistence(auth, isPersistent ? browserLocalPersistence : inMemoryPersistence)
.then(() => {
return signInWithEmailAndPassword(auth, email, password)
Expand Down
6 changes: 1 addition & 5 deletions src/page/profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ListItemText
} from "@mui/material";
import {useDispatch, useSelector} from "react-redux";
import {getLanguage, getUser, isUserPersisted} from "../../selector/Selector";
import {getLanguage, getUser} from "../../selector/Selector";
import {getAuth} from "firebase/auth";
import {clearUser, setCurrentTabIndex, setError, setLanguage} from "../../action/Action";
import {stringAvatar} from "../../utils/colorUtils";
Expand All @@ -25,7 +25,6 @@ import LanguageSelectionDialogComponent from "../../component/LanguageSelectionD
const ProfilePage = () => {
const currentUser = useSelector(getUser);
const currentLanguage = useSelector(getLanguage);
const isPersisted = useSelector(isUserPersisted);
const dispatch = useDispatch();
dispatch(setCurrentTabIndex(3));
const [open, setOpen] = useState(false);
Expand All @@ -36,9 +35,6 @@ const ProfilePage = () => {
auth.signOut()
.then(() => {
dispatch(clearUser());
if (isPersisted) {
localStorage.removeItem("user");
}
})
.catch((error) => {
console.error(error)
Expand Down
6 changes: 0 additions & 6 deletions src/reducer/Reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
SET_CURRENT_TRANSACTION_TYPE,
SET_ERROR_TYPE,
SET_LANGUAGE_TYPE,
SET_IS_USER_PERSISTED_TYPE,
SET_USER_TYPE,
UPDATE_SHOPPING_LIST_TYPE
} from "../action/Action";
Expand Down Expand Up @@ -141,11 +140,6 @@ export function eventReducer(state: GroceryState = initialState, action: Action)
...state,
language: action.payload
}
case SET_IS_USER_PERSISTED_TYPE:
return {
...state,
isUserPersisted: action.payload
}
default:
return state;
}
Expand Down
3 changes: 0 additions & 3 deletions src/selector/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,3 @@ export const getLanguage = (state: GroceryState) : string | undefined => {
return state.language;
}

export const isUserPersisted = (state: GroceryState) : boolean => {
return state.isUserPersisted;
}

0 comments on commit 81a36df

Please sign in to comment.