-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8256a3
commit 79b27e3
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createEntityAdapter, createSlice } from '@reduxjs/toolkit' | ||
import { RootState } from 'src/rtk/app/rootReducer' | ||
|
||
// TODO: remove this slice when score is not needed to be displayed anymore | ||
export type PostScore = { | ||
id: string | ||
score: number | ||
} | ||
|
||
const sliceName = 'postScore' | ||
|
||
const adapter = createEntityAdapter<PostScore>() | ||
const selectors = adapter.getSelectors<RootState>(state => state.postScores) | ||
|
||
export const selectPostScore = selectors.selectById | ||
|
||
const slice = createSlice({ | ||
name: sliceName, | ||
initialState: adapter.getInitialState(), | ||
reducers: { | ||
setPostScores: adapter.upsertMany, | ||
}, | ||
}) | ||
|
||
export const { setPostScores } = slice.actions | ||
|
||
export default slice.reducer |