diff --git a/src/components/Votes/Votes.tsx b/src/components/Votes/Votes.tsx index d116bd8ec4..37f304c5f9 100644 --- a/src/components/Votes/Votes.tsx +++ b/src/components/Votes/Votes.tsx @@ -41,7 +41,9 @@ export const Votes: FC = (props) => { return voting || allPastVotes > 0 ? (
e.stopPropagation()}> + {/* standard display for votes */} {!voting && allPastVotes > 0 && } + {/* display for votes when voting is open */} {voting && ongoingVotes.note > 0 && } {voting && (isModerator || !boardLocked) && ( 0 && !voting.allowMultipleVotes)} /> diff --git a/src/store/features/votes/reducer.ts b/src/store/features/votes/reducer.ts index 4b4912cc9e..0bbc4405ad 100644 --- a/src/store/features/votes/reducer.ts +++ b/src/store/features/votes/reducer.ts @@ -2,6 +2,7 @@ import {createReducer} from "@reduxjs/toolkit"; import {VotesState} from "./types"; import {initializeBoard} from "../board"; import {createdVote, deletedVote, updatedVotes} from "./actions"; +import {createdVoting, updatedVoting} from "../votings"; const initialState: VotesState = []; @@ -9,8 +10,10 @@ export const votesReducer = createReducer(initialState, (builder) => builder .addCase(initializeBoard, (_state, action) => action.payload.fullBoard.votes) .addCase(createdVote, (state, action) => { - state.push(action.payload); + state.unshift(action.payload); }) + .addCase(updatedVoting, (_state, action) => action.payload.notes?.map((n) => ({voting: action.payload.voting.id, note: n.id}))) .addCase(updatedVotes, (_state, action) => action.payload) .addCase(deletedVote, (state, action) => state.filter((v) => !(v.voting === action.payload.voting && v.note === action.payload.note))) + .addCase(createdVoting, () => []) ); diff --git a/src/store/features/votings/reducer.ts b/src/store/features/votings/reducer.ts index 1d9aab8c24..f2b38cc8d5 100644 --- a/src/store/features/votings/reducer.ts +++ b/src/store/features/votings/reducer.ts @@ -25,6 +25,6 @@ export const votingsReducer = createReducer(initialState, (builder) => }) .addCase(updatedVoting, (state, action) => { state.open = undefined; - state.past.push(action.payload.voting); + state.past.unshift(action.payload.voting); }) );