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
3cbccde6
Unverified
Commit
3cbccde6
authored
Nov 19, 2024
by
nlfox
Committed by
GitHub
Nov 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add pull to refresh for PagedMemoList (#4128)
parent
1424036c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
21 deletions
+51
-21
package.json
web/package.json
+1
-0
pnpm-lock.yaml
web/pnpm-lock.yaml
+14
-0
PagedMemoList.tsx
web/src/components/PagedMemoList/PagedMemoList.tsx
+36
-21
No files found.
web/package.json
View file @
3cbccde6
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
"react-leaflet"
:
"^4.2.1"
,
"react-leaflet"
:
"^4.2.1"
,
"react-redux"
:
"^9.1.2"
,
"react-redux"
:
"^9.1.2"
,
"react-router-dom"
:
"^6.27.0"
,
"react-router-dom"
:
"^6.27.0"
,
"react-simple-pull-to-refresh"
:
"^1.3.3"
,
"react-use"
:
"^17.5.1"
,
"react-use"
:
"^17.5.1"
,
"tailwind-merge"
:
"^2.5.4"
,
"tailwind-merge"
:
"^2.5.4"
,
"tailwindcss"
:
"^3.4.14"
,
"tailwindcss"
:
"^3.4.14"
,
...
...
web/pnpm-lock.yaml
View file @
3cbccde6
...
@@ -104,6 +104,9 @@ importers:
...
@@ -104,6 +104,9 @@ importers:
react-router-dom
:
react-router-dom
:
specifier
:
^6.27.0
specifier
:
^6.27.0
version
:
6.27.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
version
:
6.27.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react-simple-pull-to-refresh
:
specifier
:
^1.3.3
version
:
1.3.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react-use
:
react-use
:
specifier
:
^17.5.1
specifier
:
^17.5.1
version
:
17.5.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
version
:
17.5.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
...
@@ -2968,6 +2971,12 @@ packages:
...
@@ -2968,6 +2971,12 @@ packages:
peerDependencies
:
peerDependencies
:
react
:
'
>=16.8'
react
:
'
>=16.8'
react-simple-pull-to-refresh@1.3.3
:
resolution
:
{
integrity
:
sha512-6qXsa5RtNVmKJhLWvDLIX8UK51HFtCEGjdqQGf+M1Qjrcc4qH4fki97sgVpGEFBRwbY7DiVDA5N5p97kF16DTw==
}
peerDependencies
:
react
:
^16.10.2 || ^17.0.0 || ^18.0.0
react-dom
:
^16.10.2 || ^17.0.0 || ^18.0.0
react-style-singleton@2.2.1
:
react-style-singleton@2.2.1
:
resolution
:
{
integrity
:
sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==
}
resolution
:
{
integrity
:
sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==
}
engines
:
{
node
:
'
>=10'
}
engines
:
{
node
:
'
>=10'
}
...
@@ -6449,6 +6458,11 @@ snapshots:
...
@@ -6449,6 +6458,11 @@ snapshots:
'
@remix-run/router'
:
1.20.0
'
@remix-run/router'
:
1.20.0
react
:
18.3.1
react
:
18.3.1
react-simple-pull-to-refresh@1.3.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
:
dependencies
:
react
:
18.3.1
react-dom
:
18.3.1(react@18.3.1)
react-style-singleton@2.2.1(@types/react@18.3.12)(react@18.3.1)
:
react-style-singleton@2.2.1(@types/react@18.3.12)(react@18.3.1)
:
dependencies
:
dependencies
:
get-nonce
:
1.0.1
get-nonce
:
1.0.1
...
...
web/src/components/PagedMemoList/PagedMemoList.tsx
View file @
3cbccde6
import
{
Button
}
from
"@usememos/mui"
;
import
{
Button
}
from
"@usememos/mui"
;
import
{
ArrowDownIcon
,
LoaderIcon
}
from
"lucide-react"
;
import
{
ArrowDownIcon
,
LoaderIcon
}
from
"lucide-react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
PullToRefresh
from
"react-simple-pull-to-refresh"
;
import
{
DEFAULT_LIST_MEMOS_PAGE_SIZE
}
from
"@/helpers/consts"
;
import
{
DEFAULT_LIST_MEMOS_PAGE_SIZE
}
from
"@/helpers/consts"
;
import
{
useMemoList
,
useMemoStore
}
from
"@/store/v1"
;
import
{
useMemoList
,
useMemoStore
}
from
"@/store/v1"
;
import
{
Memo
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
Memo
}
from
"@/types/proto/api/v1/memo_service"
;
...
@@ -28,7 +29,11 @@ const PagedMemoList = (props: Props) => {
...
@@ -28,7 +29,11 @@ const PagedMemoList = (props: Props) => {
nextPageToken
:
""
,
nextPageToken
:
""
,
});
});
const
sortedMemoList
=
props
.
listSort
?
props
.
listSort
(
memoList
.
value
)
:
memoList
.
value
;
const
sortedMemoList
=
props
.
listSort
?
props
.
listSort
(
memoList
.
value
)
:
memoList
.
value
;
const
handleRefresh
=
async
()
=>
{
memoList
.
reset
();
setState
((
state
)
=>
({
...
state
,
nextPageToken
:
""
}));
fetchMoreMemos
(
""
);
};
const
setIsRequesting
=
(
isRequesting
:
boolean
)
=>
{
const
setIsRequesting
=
(
isRequesting
:
boolean
)
=>
{
setState
((
state
)
=>
({
...
state
,
isRequesting
}));
setState
((
state
)
=>
({
...
state
,
isRequesting
}));
};
};
...
@@ -53,6 +58,15 @@ const PagedMemoList = (props: Props) => {
...
@@ -53,6 +58,15 @@ const PagedMemoList = (props: Props) => {
},
[
props
.
filter
,
props
.
pageSize
]);
},
[
props
.
filter
,
props
.
pageSize
]);
return
(
return
(
<
PullToRefresh
onRefresh=
{
handleRefresh
}
pullingContent=
{
<></>
}
refreshingContent=
{
<
div
className=
"w-full flex flex-row justify-center items-center my-4"
>
<
LoaderIcon
className=
"animate-spin"
/>
</
div
>
}
>
<>
<>
{
sortedMemoList
.
map
((
memo
)
=>
props
.
renderer
(
memo
))
}
{
sortedMemoList
.
map
((
memo
)
=>
props
.
renderer
(
memo
))
}
{
state
.
isRequesting
&&
(
{
state
.
isRequesting
&&
(
...
@@ -75,6 +89,7 @@ const PagedMemoList = (props: Props) => {
...
@@ -75,6 +89,7 @@ const PagedMemoList = (props: Props) => {
</
div
>
</
div
>
)
}
)
}
</>
</>
</
PullToRefresh
>
);
);
};
};
...
...
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