Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit a388541

Browse files
committed
Removed unused actions
1 parent 71e76d7 commit a388541

File tree

5 files changed

+7
-21
lines changed

5 files changed

+7
-21
lines changed

src/background/api/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import {
1010
checkedCookies,
1111
removeTokens
1212
} from "../redux/actions/tokens";
13-
import { addUser } from "../redux/actions/user";
1413
import { AccessToken, CookieStatus } from "../redux/actions/tokenTypes";
1514
import { deleteCookie, getCookie, setCookie } from "../methods/cookies";
15+
import {updateUser} from "../redux/actions/user";
1616

1717
// reference: https://daveceddia.com/access-redux-store-outside-react/
1818

@@ -57,7 +57,7 @@ export const loginWithUsernameAndPassword = (
5757
.then((data: AxiosResponse<BackendLoginData>) => {
5858
console.log(data.data);
5959
store.dispatch(addRefreshToken(data.data.tokenValue));
60-
store.dispatch(addUser(data.data.user as UserState));
60+
store.dispatch(updateUser(data.data.user as UserState));
6161

6262
if (stayLoggedIn) {
6363
setCookie(cookieName, data.data.tokenValue, 60);
@@ -109,7 +109,7 @@ export const getAccessTokenWithRefreshToken = () => {
109109
const getOwnUserData = (userId: number) => {
110110
Axios.get<UserState>(`${hostname}${userPath}/${userId}/info`)
111111
.then((response: AxiosResponse<UserState>) => {
112-
store.dispatch(addUser(response.data));
112+
store.dispatch(updateUser(response.data));
113113
})
114114
.catch((error) => {
115115
console.log(error);

src/background/api/userInformation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface UserInformation {
1515
}
1616

1717
export const changeUserInformation = (userWithNewInformation: UserInformation): Promise<UserState> => {
18-
console.log("User given tu update user api:")
18+
console.log("[API] userinformation: User given to update user api:")
1919
console.log(userWithNewInformation)
2020
return new Promise((resolve, reject) => {
2121
return Axios.put(`${hostname}${userPath}/${userWithNewInformation.userId}/edit`, userWithNewInformation)

src/background/redux/actions/user.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {ADD_USER, AddUser, UPDATE_USER, UpdateUser, UserState} from "./userTypes";
2-
3-
export const addUser = (content: UserState):AddUser => ({
4-
type: ADD_USER,
5-
payload: content
6-
});
1+
import {UPDATE_USER, UpdateUser, UserState} from "./userTypes";
72

83
export const updateUser = (content: UserState):UpdateUser => ({
94
type: UPDATE_USER,
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export const ADD_USER = "ADD_USER";
21
export const UPDATE_USER = "UPDATE_USER";
32

43
export interface UserState {
@@ -7,14 +6,10 @@ export interface UserState {
76
groups: number[];
87
}
98

10-
export interface AddUser {
11-
type: typeof ADD_USER;
12-
payload: UserState;
13-
}
149

1510
export interface UpdateUser {
1611
type: typeof UPDATE_USER;
1712
payload: UserState;
1813
}
1914

20-
export type UserActionTypes = AddUser | UpdateUser;
15+
export type UserActionTypes = UpdateUser;

src/background/redux/reducers/user.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ADD_USER, UPDATE_USER, UserActionTypes, UserState} from "../actions/userTypes";
1+
import {UPDATE_USER, UserActionTypes, UserState} from "../actions/userTypes";
22

33
const initialState: UserState = {
44
groups: [],
@@ -8,10 +8,6 @@ const initialState: UserState = {
88

99
export default function users(state = initialState, action: UserActionTypes) {
1010
switch (action.type) {
11-
case ADD_USER: {
12-
console.log("[Redux] adding user");
13-
return action.payload;
14-
}
1511
case UPDATE_USER: {
1612
console.log("[Redux] updating user");
1713
return action.payload;

0 commit comments

Comments
 (0)