Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
374f3f7d
Commit
374f3f7d
authored
Feb 03, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix filter initial state
parent
8340e6b2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
filter.ts
web/src/store/module/filter.ts
+1
-4
filter.ts
web/src/store/reducer/filter.ts
+15
-1
No files found.
web/src/store/module/filter.ts
View file @
374f3f7d
import
store
,
{
useAppSelector
}
from
".."
;
import
store
,
{
useAppSelector
}
from
".."
;
import
{
Filter
,
setFilter
}
from
"../reducer/filter"
;
import
{
setFilter
}
from
"../reducer/filter"
;
export
const
useFilterStore
=
()
=>
{
export
const
useFilterStore
=
()
=>
{
const
state
=
useAppSelector
((
state
)
=>
state
.
filter
);
const
state
=
useAppSelector
((
state
)
=>
state
.
filter
);
...
@@ -9,9 +9,6 @@ export const useFilterStore = () => {
...
@@ -9,9 +9,6 @@ export const useFilterStore = () => {
getState
:
()
=>
{
getState
:
()
=>
{
return
store
.
getState
().
filter
;
return
store
.
getState
().
filter
;
},
},
setFilter
:
(
filter
:
Filter
)
=>
{
store
.
dispatch
(
setFilter
(
filter
));
},
clearFilter
:
()
=>
{
clearFilter
:
()
=>
{
store
.
dispatch
(
store
.
dispatch
(
setFilter
({
setFilter
({
...
...
web/src/store/reducer/filter.ts
View file @
374f3f7d
...
@@ -8,9 +8,23 @@ interface State {
...
@@ -8,9 +8,23 @@ interface State {
export
type
Filter
=
State
;
export
type
Filter
=
State
;
const
getInitialState
=
():
State
=>
{
const
state
:
State
=
{};
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
const
tag
=
urlParams
.
get
(
"tag"
);
const
text
=
urlParams
.
get
(
"text"
);
if
(
tag
)
{
state
.
tag
=
tag
;
}
if
(
text
)
{
state
.
text
=
text
;
}
return
state
;
};
const
filterSlice
=
createSlice
({
const
filterSlice
=
createSlice
({
name
:
"filter"
,
name
:
"filter"
,
initialState
:
{}
as
State
,
initialState
:
getInitialState
()
,
reducers
:
{
reducers
:
{
setFilter
:
(
state
,
action
:
PayloadAction
<
Partial
<
State
>>
)
=>
{
setFilter
:
(
state
,
action
:
PayloadAction
<
Partial
<
State
>>
)
=>
{
if
(
JSON
.
stringify
(
action
.
payload
)
===
state
)
{
if
(
JSON
.
stringify
(
action
.
payload
)
===
state
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment