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
da80d4ef
Unverified
Commit
da80d4ef
authored
Nov 14, 2022
by
Zeng1998
Committed by
GitHub
Nov 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: duration query string (#465)
parent
205ad0fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
location.ts
web/src/store/modules/location.ts
+15
-12
No files found.
web/src/store/modules/location.ts
View file @
da80d4ef
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
import
{
parse
,
ParsedQs
}
from
"qs"
;
interface
Duration
{
interface
Duration
{
from
:
number
;
from
:
number
;
...
@@ -31,7 +32,7 @@ const getValidPathname = (pathname: string): string => {
...
@@ -31,7 +32,7 @@ const getValidPathname = (pathname: string): string => {
const
getStateFromLocation
=
()
=>
{
const
getStateFromLocation
=
()
=>
{
const
{
pathname
,
search
,
hash
}
=
window
.
location
;
const
{
pathname
,
search
,
hash
}
=
window
.
location
;
const
urlParams
=
new
URLSearchParams
(
search
);
const
urlParams
=
parse
(
search
.
slice
(
1
)
);
const
state
:
State
=
{
const
state
:
State
=
{
pathname
:
getValidPathname
(
pathname
),
pathname
:
getValidPathname
(
pathname
),
hash
:
hash
,
hash
:
hash
,
...
@@ -40,20 +41,22 @@ const getStateFromLocation = () => {
...
@@ -40,20 +41,22 @@ const getStateFromLocation = () => {
if
(
search
!==
""
)
{
if
(
search
!==
""
)
{
state
.
query
=
{};
state
.
query
=
{};
state
.
query
.
tag
=
urlParams
.
get
(
"tag"
)
??
undefined
;
state
.
query
.
tag
=
urlParams
[
"tag"
]
as
string
;
state
.
query
.
type
=
(
urlParams
.
get
(
"type"
)
as
MemoSpecType
)
??
undefined
;
state
.
query
.
type
=
urlParams
[
"type"
]
as
MemoSpecType
;
state
.
query
.
text
=
urlParams
.
get
(
"text"
)
??
undefined
;
state
.
query
.
text
=
urlParams
[
"text"
]
as
string
;
const
shortcutIdStr
=
urlParams
.
get
(
"shortcutId"
)
;
const
shortcutIdStr
=
urlParams
[
"shortcutId"
]
as
string
;
state
.
query
.
shortcutId
=
shortcutIdStr
?
Number
(
shortcutIdStr
)
:
undefined
;
state
.
query
.
shortcutId
=
shortcutIdStr
?
Number
(
shortcutIdStr
)
:
undefined
;
const
from
=
parseInt
(
urlParams
.
get
(
"from"
)
??
"0"
);
const
durationObj
=
urlParams
[
"duration"
]
as
ParsedQs
;
const
to
=
parseInt
(
urlParams
.
get
(
"to"
)
??
"0"
);
if
(
durationObj
)
{
if
(
to
>
from
&&
to
!==
0
)
{
const
duration
:
Duration
=
{
state
.
query
.
duration
=
{
from
:
Number
(
durationObj
[
"from"
]),
from
,
to
:
Number
(
durationObj
[
"to"
]),
to
,
};
};
if
(
duration
.
to
>
duration
.
from
&&
duration
.
to
!==
0
)
{
state
.
query
.
duration
=
duration
;
}
}
}
state
.
query
.
visibility
=
(
urlParams
.
get
(
"visibility"
)
as
Visibility
)
??
undefined
;
state
.
query
.
visibility
=
urlParams
[
"visibility"
]
as
Visibility
;
}
}
return
state
;
return
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