Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: redux store #4485

Merged
merged 147 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 145 commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
237e0f5
upgrade redux toolkit to ^2.2.7
Schwehn42 Aug 22, 2024
1790b86
boardSlice initializeBoard action
Schwehn42 Aug 22, 2024
ecacd14
add board actions
Schwehn42 Aug 22, 2024
5ca8704
board reducer timer actions
Schwehn42 Aug 27, 2024
b88a625
board status actions
Schwehn42 Aug 27, 2024
4466d24
todos
Schwehn42 Aug 27, 2024
f15dab2
rename slice -> reducer
Schwehn42 Aug 27, 2024
209f6f2
remove unneccesary comment
Schwehn42 Aug 27, 2024
1dee944
export reducer
Schwehn42 Aug 27, 2024
cd1fdda
rename file again
Schwehn42 Aug 27, 2024
9f2afb1
move types and actions to separate files
Schwehn42 Aug 27, 2024
d98b4df
add auth actions, types, index
Schwehn42 Aug 27, 2024
f3fa165
add auth reducer
Schwehn42 Aug 27, 2024
cd3f087
fix board reducer deleting data property
Schwehn42 Aug 27, 2024
13d1e0e
add comment
Schwehn42 Aug 27, 2024
c1f5a11
add board reducer, actions, types
Schwehn42 Aug 28, 2024
536fceb
directory plural
Schwehn42 Aug 28, 2024
903fb30
columns reducer p1
Schwehn42 Aug 29, 2024
81117ef
init and update cols
Schwehn42 Aug 29, 2024
8707273
note action, reducer, types
Schwehn42 Aug 29, 2024
3df194f
param name
Schwehn42 Aug 29, 2024
da54a53
participants actions, types
Schwehn42 Aug 29, 2024
7258c64
participants reducer p1
Schwehn42 Aug 29, 2024
ad4c6cd
add other participants cases
Schwehn42 Aug 29, 2024
2f8ae2c
simplify updatedBoardTimer
Schwehn42 Aug 30, 2024
5f06b86
reaction actions, reducer, types
Schwehn42 Aug 30, 2024
81dbc8c
requests actions, reducer, types
Schwehn42 Aug 30, 2024
65ed671
skinTone actions, reducer, types
Schwehn42 Aug 30, 2024
a3bd454
add action export to participants, notes
Schwehn42 Aug 30, 2024
b09358a
view actions, reducer, types
Schwehn42 Aug 30, 2024
90f3e7b
votes actions, reducer, types
Schwehn42 Aug 30, 2024
3b68791
rename folder vote -> votes
Schwehn42 Aug 30, 2024
4d3011e
reactions plural folder
Schwehn42 Aug 30, 2024
8a7f39f
notes index export type
Schwehn42 Aug 30, 2024
25652b1
votings actions, reducer, types
Schwehn42 Aug 30, 2024
42850b5
move all features to temp folder
Schwehn42 Aug 30, 2024
1f1763c
move old actions to respective features
Schwehn42 Aug 30, 2024
7e09d6b
rename files to actions
Schwehn42 Aug 30, 2024
a34bb8b
actions content
Schwehn42 Aug 30, 2024
5596e4e
move types
Schwehn42 Aug 30, 2024
652a58f
rename to */types
Schwehn42 Aug 30, 2024
9c5a18b
copy from tmp
Schwehn42 Aug 30, 2024
5f63422
move from reducer to features
Schwehn42 Aug 30, 2024
3517f6f
rename reducers -> */reducer.ts
Schwehn42 Aug 30, 2024
b9ecf05
copy reducers from tmp
Schwehn42 Aug 30, 2024
115e052
add index file to each features
Schwehn42 Aug 30, 2024
cf6aa10
remove tmp features
Schwehn42 Aug 30, 2024
f0a49bc
move auth middleware to features
Schwehn42 Sep 2, 2024
3398a58
rename to thunks
Schwehn42 Sep 2, 2024
b1bf01d
auth thunk and action/reducer adjustments
Schwehn42 Sep 3, 2024
43537fc
move middleware to features
Schwehn42 Sep 3, 2024
bef7453
rename middleware -> thunks
Schwehn42 Sep 3, 2024
d8ef2be
temp board mw
Schwehn42 Sep 3, 2024
68c2930
setTimer thunk
Schwehn42 Sep 3, 2024
b3b3abe
cancelTimer, incrementTimer thunk
Schwehn42 Sep 3, 2024
28e1999
change initAuth to createAsyncThunk
Schwehn42 Sep 3, 2024
be4defa
editBoard thunk
Schwehn42 Sep 3, 2024
7fe17a5
shareNote thunk
Schwehn42 Sep 3, 2024
49385c7
stopSharing thunk
Schwehn42 Sep 3, 2024
c909a3a
deleteBoard thunk
Schwehn42 Sep 3, 2024
327e99f
import
Schwehn42 Sep 3, 2024
44ae9a5
tmp -> thunks
Schwehn42 Sep 3, 2024
5ab0433
board reducer import
Schwehn42 Sep 3, 2024
d753fdd
omit param type
Schwehn42 Sep 3, 2024
26301ef
boardReactions thunk
Schwehn42 Sep 3, 2024
5bc4cac
columns thunks
Schwehn42 Sep 4, 2024
1968293
notes thunks
Schwehn42 Sep 4, 2024
8909d43
participants thunks
Schwehn42 Sep 4, 2024
2c2c40a
reactions thunks
Schwehn42 Sep 4, 2024
2df64a4
temp joinBoard thunk
Schwehn42 Sep 4, 2024
7ea9204
switch
Schwehn42 Sep 4, 2024
fd8448f
pendingBoardAccesConfirmation
Schwehn42 Sep 4, 2024
706176e
setRoute
Schwehn42 Sep 4, 2024
2f76cc8
accept/rejectJoinRequest thunks
Schwehn42 Sep 4, 2024
dc6ab81
change order
Schwehn42 Sep 4, 2024
ebb9968
tmp -> thunks
Schwehn42 Sep 4, 2024
99b0ea9
skinTone thunks
Schwehn42 Sep 4, 2024
1fb4743
setRoute fix
Schwehn42 Sep 4, 2024
ccf32d2
initApplication thunk
Schwehn42 Sep 4, 2024
86ce8af
view thunks
Schwehn42 Sep 4, 2024
a2d60fa
votes thunks
Schwehn42 Sep 5, 2024
77127d0
votings thunks
Schwehn42 Sep 5, 2024
fe5a616
thunks file type tsx -> ts
Schwehn42 Sep 5, 2024
a7a29a2
mv index -> store
Schwehn42 Sep 5, 2024
58d748c
reducer plural
Schwehn42 Sep 5, 2024
6b0cfe2
feature index file
Schwehn42 Sep 5, 2024
32fee97
rm old action index
Schwehn42 Sep 5, 2024
fb89b64
new configureStore
Schwehn42 Sep 5, 2024
8a3662d
redefine ApplicationState
Schwehn42 Sep 5, 2024
d94dee8
comment duplicate actions
Schwehn42 Sep 5, 2024
57529fd
export all thunks
Schwehn42 Sep 5, 2024
36fabcc
rm unused import
Schwehn42 Sep 5, 2024
6413206
fix leaveBoard not being a thunk
Schwehn42 Sep 5, 2024
1db9547
useAppSelector
Schwehn42 Sep 5, 2024
50aabeb
useAppDispatch
Schwehn42 Sep 5, 2024
eb1e0f4
setShowHiddenColumns thunk use self id from context
Schwehn42 Sep 5, 2024
df97b19
forgot setUserReadyStatus thunk
Schwehn42 Sep 5, 2024
8fd3f3a
fix store import
Schwehn42 Sep 5, 2024
28b4a10
unstackNote: remove unused param
Schwehn42 Sep 5, 2024
f547aee
refactor all components for new dispatch/actions
Schwehn42 Sep 5, 2024
a5966a8
one more store import fix
Schwehn42 Sep 5, 2024
22bbc7b
dispatch in index.tsx
Schwehn42 Sep 5, 2024
48a13b2
dispatch in i18n
Schwehn42 Sep 5, 2024
24bec37
also fixup route components
Schwehn42 Sep 5, 2024
6b4f826
another one in utils
Schwehn42 Sep 5, 2024
790bf67
remove an action
Schwehn42 Sep 5, 2024
0dc2e4b
getTestApplicationState correct type import
Schwehn42 Sep 5, 2024
23d2a1e
fix test related errors
Schwehn42 Sep 6, 2024
f7a546f
lint fixes
Schwehn42 Sep 6, 2024
11e9797
Merge branch 'main' into js/refactor-store
Schwehn42 Sep 6, 2024
a4a64b7
import order
Schwehn42 Sep 6, 2024
43b9d99
fix serverInfo
Schwehn42 Sep 6, 2024
9a0bf2f
call correct initAuth
Schwehn42 Sep 6, 2024
37b39bd
participants reducer without store
Schwehn42 Sep 6, 2024
9a6f3b9
board reducer without store
Schwehn42 Sep 6, 2024
28c3b59
view reducer without store
Schwehn42 Sep 6, 2024
2459445
adjust rest of the reducers
Schwehn42 Sep 6, 2024
a3996cd
dispatch board thunks with the new props
Schwehn42 Sep 6, 2024
14a48ba
typo
Schwehn42 Sep 6, 2024
30983be
fix updatedColumns action not being called
Schwehn42 Sep 6, 2024
e90f593
fix createColumnsOptimistically
Schwehn42 Sep 9, 2024
631aa43
var name fix
Schwehn42 Sep 9, 2024
a88d0b8
delete todo
Schwehn42 Sep 9, 2024
ff42f03
updatedBoard
Schwehn42 Sep 9, 2024
3f73ef5
remove commented actions
Schwehn42 Sep 9, 2024
c9f4038
action name prefix
Schwehn42 Sep 9, 2024
63e633b
setRoute action to view, close request socket
Schwehn42 Sep 9, 2024
5a96c2b
add generic retryWithToast function
Schwehn42 Sep 9, 2024
27b1870
return promise
Schwehn42 Sep 9, 2024
95ee428
apply retryable to auth thunks
Schwehn42 Sep 9, 2024
721b891
apply retryable to board thunks
Schwehn42 Sep 9, 2024
0a1ddc0
apply retryable to columns thunks
Schwehn42 Sep 9, 2024
9a27639
apply retryable to notes thunks
Schwehn42 Sep 10, 2024
0e1f747
apply retryable to participants thunks
Schwehn42 Sep 10, 2024
719f049
setUserBanned toast
Schwehn42 Sep 10, 2024
303c2f5
retryable requests thunks
Schwehn42 Sep 10, 2024
6ec9c31
retryable view thunks
Schwehn42 Sep 10, 2024
1118883
retryable votes thunks
Schwehn42 Sep 10, 2024
b10a043
retryable votings thunks
Schwehn42 Sep 10, 2024
cd9b4b3
mock
Schwehn42 Sep 10, 2024
8e28f90
import
Schwehn42 Sep 10, 2024
e4d4a6c
remove some tests
Schwehn42 Sep 10, 2024
4c8ad2e
add markdown store explanation
Schwehn42 Sep 10, 2024
c177d69
Merge branch 'main' into js/refactor-store
Schwehn42 Sep 25, 2024
4f84668
columnsettings, colorpicker: use new dispatch and actions
Schwehn42 Sep 25, 2024
432bba4
remove default middleware
Schwehn42 Sep 26, 2024
359e34d
Merge branch 'main' into js/refactor-store
Schwehn42 Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@fontsource/raleway": "^5.1.0",
"@react-hook/resize-observer": "^2.0.2",
"@react-spring/web": "^9.7.4",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.2.7",
"avataaars": "^2.0.0",
"classnames": "^2.5.1",
"file-saver": "^2.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SERVER_HTTP_URL} from "../config";
import {AuthDto} from "../types/auth";
import {AuthDto} from "../store/features/auth/types";

export const AuthAPI = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/board.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Color} from "constants/colors";
import {EditBoardRequest} from "types/board";
import {EditBoardRequest} from "store/features/board/types";
import {SERVER_HTTP_URL} from "../config";

export const BoardAPI = {
Expand Down
4 changes: 2 additions & 2 deletions src/api/boardReaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {SERVER_HTTP_URL} from "config";
import {ReactionType} from "types/reaction";
import {BoardReactionType} from "types/boardReaction";
import {ReactionType} from "store/features/reactions/types";
import {BoardReactionType} from "store/features/boardReactions/types";

export const BoardReactionAPI = {
addBoardReaction: async (boardId: string, reactionType: ReactionType) => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/column.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {EditColumnRequest} from "types/column";
import {ColumnWithoutId} from "store/features/columns/types";
import {SERVER_HTTP_URL} from "../config";

export const ColumnAPI = {
Expand All @@ -14,7 +14,7 @@ export const ColumnAPI = {
*
* @returns a {status, description} object
*/
editColumn: async (boardId: string, columnId: string, column: EditColumnRequest) => {
editColumn: async (boardId: string, columnId: string, column: ColumnWithoutId) => {
try {
const response = await fetch(`${SERVER_HTTP_URL}/boards/${boardId}/columns/${columnId}`, {
method: "PUT",
Expand Down
15 changes: 12 additions & 3 deletions src/api/info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {SERVER_HTTP_URL} from "../config";
import {SERVER_HTTP_URL} from "config";
import {ServerInfo} from "store/features";

interface ServerInformation {
// type as received from the backend
interface ServerInformationDto {
anonymousLoginDisabled: boolean;
authProvider: string[];
serverTime: string;
Expand All @@ -21,7 +23,14 @@ export const InfoAPI = {
const response = await fetch(`${SERVER_HTTP_URL}/info`);

if (response.status === 200) {
return (await response.json()) as ServerInformation;
const info = (await response.json()) as ServerInformationDto;
// convert to frontend type, don't ask me why they're different in the first place though
return {
serverTime: new Date(info.serverTime).getTime(),
enabledAuthProvider: info.authProvider,
anonymousLoginDisabled: info.anonymousLoginDisabled,
feedbackEnabled: info.feedbackEnabled,
} as ServerInfo;
}

throw new Error(`responded with status code ${response.status}`);
Expand Down
2 changes: 1 addition & 1 deletion src/api/note.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SERVER_HTTP_URL} from "../config";
import {EditNote, Note} from "../types/note";
import {EditNote, Note} from "../store/features/notes/types";

export const NoteAPI = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/participant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Participant} from "types/participant";
import {Participant} from "store/features/participants/types";
import {SERVER_HTTP_URL} from "../config";

export const ParticipantsAPI = {
Expand Down
2 changes: 1 addition & 1 deletion src/api/reaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SERVER_HTTP_URL} from "../config";
import {Reaction, ReactionType} from "../types/reaction";
import {Reaction, ReactionType} from "../store/features/reactions/types";

export const ReactionAPI = {
addReaction: async (board: string, note: string, reactionType: ReactionType) => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Request} from "types/request";
import {Request} from "store/features/requests/types";
import {SERVER_HTTP_URL} from "../config";

export const RequestAPI = {
Expand Down
2 changes: 1 addition & 1 deletion src/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Auth} from "types/auth";
import {Auth} from "store/features/auth/types";
import {SERVER_HTTP_URL} from "../config";

export const UserAPI = {
Expand Down
2 changes: 1 addition & 1 deletion src/api/vote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SERVER_HTTP_URL} from "../config";
import {Vote} from "../types/vote";
import {Vote} from "../store/features/votes/types";

export const VoteAPI = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/votings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CreateVotingRequest} from "types/voting";
import {CreateVotingRequest} from "store/features/votings/types";
import {SERVER_HTTP_URL} from "../config";

export const VotingAPI = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {FC, useState} from "react";
import "./AccessPolicySelection.scss";
import {AccessPolicy} from "types/board";
import {AccessPolicy} from "store/features/board/types";
import {generateRandomString} from "utils/random";
import {useTranslation} from "react-i18next";
import {Visible, Hidden, Duplicate, Refresh} from "components/Icon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {fireEvent, waitFor} from "@testing-library/react";
import {AccessPolicySelection} from "components/AccessPolicySelection/AccessPolicySelection";
import {AccessPolicy} from "types/board";
import {AccessPolicy} from "store/features/board/types";
import {render} from "testUtils";

describe("AccessPolicySelection", () => {
Expand Down
7 changes: 4 additions & 3 deletions src/components/BoardHeader/BoardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import {useState, VFC} from "react";
import {LockClosed, Open as Globe, KeyProtected, Share} from "components/Icon";
import {BoardUsers} from "components/BoardUsers";
import store, {useAppSelector} from "store";
import {useAppDispatch, useAppSelector} from "store";
import {ScrumlrLogo} from "components/ScrumlrLogo";
import {HeaderMenu} from "components/BoardHeader/HeaderMenu";
import {useTranslation} from "react-i18next";
import {Actions} from "store/action";
import {ConfirmationDialog} from "components/ConfirmationDialog";
import {shallowEqual} from "react-redux";
import "./BoardHeader.scss";
import {ShareButton} from "components/ShareButton";
import {Tooltip} from "react-tooltip";
import {leaveBoard} from "store/features";
import {DEFAULT_BOARD_NAME} from "../../constants/misc";

export interface BoardHeaderProps {
currentUserIsModerator: boolean;
}

export const BoardHeader: VFC<BoardHeaderProps> = (props) => {
const dispatch = useAppDispatch();
const {t} = useTranslation();
const state = useAppSelector(
(rootState) => ({
Expand All @@ -36,7 +37,7 @@ export const BoardHeader: VFC<BoardHeaderProps> = (props) => {
<ConfirmationDialog
title={t("ConfirmationDialog.returnToHomepage")}
onAccept={() => {
store.dispatch(Actions.leaveBoard());
dispatch(leaveBoard());
window.location.pathname = "/";
}}
onDecline={() => setShowConfirmationDialog(false)}
Expand Down
11 changes: 6 additions & 5 deletions src/components/BoardHeader/HeaderMenu/BoardOptions/LockBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import store, {useAppSelector} from "store";
import {useAppDispatch, useAppSelector} from "store";
import {useTranslation} from "react-i18next";
import {Actions} from "store/action";
import {editBoard} from "store/features";
import {BoardOption} from "./BoardOption";
import {BoardOptionButton} from "./BoardOptionButton";
import {BoardOptionToggle} from "./BoardOptionToggle";
import "../BoardSettings/BoardSettings.scss";

export const LockBoard = () => {
const dispatch = useAppDispatch();
const {t} = useTranslation();
const allowEditing = useAppSelector((state) => state.board.data!.isLocked);
const isLocked = useAppSelector((state) => state.board.data!.isLocked);

return (
<BoardOption>
<BoardOptionButton aria-checked={allowEditing} role="switch" label={t("BoardSettings.IsLocked")} onClick={() => store.dispatch(Actions.editBoard({isLocked: !allowEditing}))}>
<BoardOptionToggle active={allowEditing} />
<BoardOptionButton aria-checked={isLocked} role="switch" label={t("BoardSettings.IsLocked")} onClick={() => dispatch(editBoard({isLocked: !isLocked}))}>
<BoardOptionToggle active={isLocked} />
</BoardOptionButton>
</BoardOption>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import {useAppSelector} from "store";
import {useDispatch} from "react-redux";
import {useAppDispatch, useAppSelector} from "store";
import {editBoard} from "store/features";
import {useTranslation} from "react-i18next";
import {Actions} from "store/action";
import {BoardOption} from "./BoardOption";
import {BoardOptionButton} from "./BoardOptionButton";
import {BoardOptionToggle} from "./BoardOptionToggle";
import "../BoardSettings/BoardSettings.scss";

export const ShowAuthorOption = () => {
const {t} = useTranslation();
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const showAuthors = useAppSelector((state) => state.board.data?.showAuthors);

return (
<BoardOption data-testid="author">
<BoardOptionButton
label={t("BoardSettings.ShowAuthorOption")}
onClick={() => {
dispatch(Actions.editBoard({showAuthors: !showAuthors}));
dispatch(editBoard({showAuthors: !showAuthors}));
}}
>
<BoardOptionToggle active={!!showAuthors} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import {useAppSelector} from "store";
import {useAppDispatch, useAppSelector} from "store";
import {setShowHiddenColumns} from "store/features";
import {useTranslation} from "react-i18next";
import {useDispatch} from "react-redux";
import {Actions} from "store/action";
import {BoardOption} from "./BoardOption";
import {BoardOptionButton} from "./BoardOptionButton";
import {BoardOptionToggle} from "./BoardOptionToggle";
import "../BoardSettings/BoardSettings.scss";

export const ShowHiddenColumnsOption = () => {
const {t} = useTranslation();
const showHiddenColumns = useAppSelector((state) => state.participants?.self.showHiddenColumns);
const dispatch = useDispatch();
const showHiddenColumns = useAppSelector((state) => !!state.participants?.self?.showHiddenColumns);
const dispatch = useAppDispatch();

return (
<BoardOption data-testid="column">
<BoardOptionButton
label={t("BoardSettings.ShowHiddenColumnsOption")}
onClick={() => {
dispatch(Actions.setShowHiddenColumns(!showHiddenColumns));
dispatch(setShowHiddenColumns({showHiddenColumns: !showHiddenColumns}));
}}
>
<BoardOptionToggle active={!!showHiddenColumns} />
<BoardOptionToggle active={showHiddenColumns} />
</BoardOptionButton>
</BoardOption>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import {useAppSelector} from "store";
import {useDispatch} from "react-redux";
import {useAppDispatch, useAppSelector} from "store";
import {editBoard} from "store/features";
import {useTranslation} from "react-i18next";
import {Actions} from "store/action";
import {BoardOption} from "./BoardOption";
import {BoardOptionButton} from "./BoardOptionButton";
import {BoardOptionToggle} from "./BoardOptionToggle";
import "../BoardSettings/BoardSettings.scss";

export const ShowOtherUsersNotesOption = () => {
const {t} = useTranslation();
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const showNotesOfOtherParticipants = useAppSelector((state) => state.board.data?.showNotesOfOtherUsers);

return (
<BoardOption data-testid="note">
<BoardOptionButton
label={t("BoardSettings.ShowOtherUsersNotesOption")}
onClick={() => {
dispatch(Actions.editBoard({showNotesOfOtherUsers: !showNotesOfOtherParticipants}));
dispatch(editBoard({showNotesOfOtherUsers: !showNotesOfOtherParticipants}));
}}
>
<BoardOptionToggle active={!!showNotesOfOtherParticipants} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import "./BoardSettings.scss";
import {Dispatch, SetStateAction, useState} from "react";
import store, {useAppSelector} from "store";
import {ApplicationState} from "types";
import {Actions} from "store/action";
import {ApplicationState, useAppDispatch, useAppSelector} from "store";
import {useTranslation} from "react-i18next";
import {DEFAULT_BOARD_NAME} from "constants/misc";
import {editBoard} from "store/features";

export type BoardSettingsProps = {
activeEditMode: boolean;
Expand All @@ -13,14 +12,15 @@ export type BoardSettingsProps = {
};

export const BoardSettings = (props: BoardSettingsProps) => {
const dispatch = useAppDispatch();
const {t} = useTranslation();
const name = useAppSelector((state: ApplicationState) => state.board.data!.name) ?? "";

const [boardName, setBoardName] = useState(name);

const onSubmit = () => {
if (props.activeEditMode && name !== boardName) {
store.dispatch(Actions.editBoard({name: boardName}));
dispatch(editBoard({name: boardName}));
}
props.setActiveEditMode(!props.activeEditMode);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/BoardHeader/__tests__/BoardHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {render} from "testUtils";
import {Provider} from "react-redux";
import {BoardHeader} from "components/BoardHeader/BoardHeader";
import getTestStore from "utils/test/getTestStore";
import {ApplicationState} from "types";
import {ApplicationState} from "store";
import i18n from "i18nTest";

const createBoardHeader = (overwrite?: Partial<ApplicationState>) => {
Expand Down Expand Up @@ -70,6 +70,7 @@ describe("Board Header", () => {
showNotesOfOtherUsers: true,
allowStacking: true,
showNoteReactions: true,
isLocked: false,
},
},
})
Expand Down
6 changes: 3 additions & 3 deletions src/components/BoardReaction/BoardReaction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BOARD_REACTION_EMOJI_MAP, BoardReactionType} from "types/boardReaction";
import {BOARD_REACTION_EMOJI_MAP, BoardReactionType} from "store/features/boardReactions/types";
import {memo, useEffect, useRef, useState} from "react";
import {getRandomNumberInRange} from "utils/random";
import {useAppSelector} from "store";
Expand All @@ -18,8 +18,8 @@ export const BoardReaction = memo((props: BoardReactionProps) => {
const [displayOffset, setDisplayOffset] = useState<number>(-100);
const {t} = useTranslation();
const emoji = BOARD_REACTION_EMOJI_MAP.get(props.reaction.reactionType);
const me = useAppSelector((state) => state.participants!.self);
const others = useAppSelector((state) => state.participants!.others);
const me = useAppSelector((state) => state.participants!.self)!;
const others = useAppSelector((state) => state.participants!.others) ?? [];
const skinTone = useAppSelector((state) => state.skinTone);
const all = [me, ...others];
const reactionUser = all.find((p) => p.user.id === props.reaction.user)!;
Expand Down
15 changes: 7 additions & 8 deletions src/components/BoardReactionMenu/BoardReactionMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {ForwardedRef, forwardRef, MouseEvent} from "react";
import {Close} from "components/Icon";
import {ReactionType} from "types/reaction";
import {BOARD_REACTION_EMOJI_MAP} from "types/boardReaction";
import {Actions} from "store/action";
import {useDispatch} from "react-redux";
import {ReactionType} from "store/features/reactions/types";
import {BOARD_REACTION_EMOJI_MAP} from "store/features/boardReactions/types";
import {useHotkeys} from "react-hotkeys-hook";
import {useAppSelector} from "store";
import {useAppDispatch, useAppSelector} from "store";
import {Toast} from "utils/Toast";
import {useTranslation} from "react-i18next";
import {useDelayedReset} from "utils/hooks/useDelayedReset";
import {animated, useTransition} from "@react-spring/web";
import "./BoardReactionMenu.scss";
import {addBoardReaction, setShowBoardReactions} from "store/features";

type BoardReactionMenuProps = {
showMenu: boolean;
Expand All @@ -20,7 +19,7 @@ type BoardReactionMenuProps = {
const REACTION_DEBOUNCE_TIME = 300; // milliseconds

export const BoardReactionMenu = forwardRef((props: BoardReactionMenuProps, ref: ForwardedRef<HTMLDivElement>) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const {t} = useTranslation();

const boardReactions = [...BOARD_REACTION_EMOJI_MAP];
Expand All @@ -37,12 +36,12 @@ export const BoardReactionMenu = forwardRef((props: BoardReactionMenuProps, ref:
Toast.info({
title: t("Toast.boardReactionsDisabled"),
buttons: [t("Toast.enable")],
firstButtonOnClick: () => dispatch(Actions.setShowBoardReactions(true)),
firstButtonOnClick: () => dispatch(setShowBoardReactions(true)),
});
} else if (debounce) {
// not ready yet
} else {
dispatch(Actions.addBoardReaction(reaction));
dispatch(addBoardReaction(reaction));
resetDebounce();
}
};
Expand Down
Loading
Loading