Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
395d59c3
Commit
395d59c3
authored
Jul 31, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize pull deck progress
parent
afdee64c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
55 deletions
+28
-55
src/api/mdproDeck/pull.ts
src/api/mdproDeck/pull.ts
+4
-9
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
+21
-46
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+3
-0
No files found.
src/api/mdproDeck/pull.ts
View file @
395d59c3
import
{
useConfig
}
from
"
@/config
"
;
import
{
pfetch
}
from
"
@/infra
"
;
import
{
handleHttps
}
from
"
..
"
;
import
{
MdproDeckLike
,
MdproResp
}
from
"
./schema
"
;
...
...
@@ -32,7 +31,6 @@ interface RespData {
export
async
function
pullDecks
(
req
:
PullReq
=
defaultPullReq
,
progressCallback
?:
(
progress
:
number
)
=>
void
,
):
Promise
<
MdproResp
<
RespData
>
|
undefined
>
{
const
myHeaders
=
mdproHeaders
();
...
...
@@ -46,13 +44,10 @@ export async function pullDecks(
const
url
=
new
URL
(
`
${
mdproServer
}
/
${
API_PATH
}
`
);
url
.
search
=
params
.
toString
();
const
resp
=
await
pfetch
(
url
.
toString
(),
{
init
:
{
const
resp
=
await
fetch
(
url
.
toString
(),
{
method
:
"
GET
"
,
headers
:
myHeaders
,
redirect
:
"
follow
"
,
},
progressCallback
,
});
return
await
handleHttps
(
resp
,
API_PATH
);
...
...
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
View file @
395d59c3
...
...
@@ -25,7 +25,7 @@ interface Props {
decks
:
MdproDeckLike
[];
total
:
number
;
onlyMine
:
boolean
;
progress
:
number
;
loaded
:
boolean
;
}
// TODO: useConfig
...
...
@@ -38,7 +38,7 @@ const store = proxy<Props>({
decks
:
[],
total
:
0
,
onlyMine
:
false
,
progress
:
0.01
,
loaded
:
false
,
});
export
const
DeckResults
:
React
.
FC
=
memo
(()
=>
{
...
...
@@ -46,7 +46,7 @@ export const DeckResults: React.FC = memo(() => {
const
{
message
}
=
App
.
useApp
();
const
{
t
:
i18n
}
=
useTranslation
(
"
DeckResults
"
);
useEffect
(()
=>
{
reset
Progress
();
reset
Loaded
();
if
(
snap
.
onlyMine
)
{
// show only decks uploaded by myself
...
...
@@ -56,29 +56,11 @@ export const DeckResults: React.FC = memo(() => {
}
},
[
snap
.
query
,
snap
.
page
,
snap
.
onlyMine
]);
const
onChangePage
=
async
(
page
:
number
)
=>
{
const
resp
=
await
pullDecks
({
page
,
size
:
PAGE_SIZE
,
keyWord
:
store
.
query
!==
""
?
store
.
query
:
undefined
,
sortLike
:
SORT_LIKE
,
});
if
(
resp
?.
data
)
{
const
{
current
,
total
,
records
}
=
resp
.
data
;
store
.
page
=
current
;
store
.
total
=
total
;
store
.
decks
=
records
;
}
else
if
(
resp
?.
code
!==
0
)
{
message
.
error
(
resp
?.
message
);
}
else
{
message
.
error
(
"
翻页失败,请检查您的网络状况。
"
);
}
};
const
onChangePage
=
(
page
:
number
)
=>
(
store
.
page
=
page
);
return
(
<>
{
snap
.
progress
===
1
?
(
{
snap
.
loaded
?
(
snap
.
decks
.
length
?
(
<
div
className=
{
styles
.
container
}
>
<
div
className=
{
styles
[
"
search-decks
"
]
}
>
...
...
@@ -109,7 +91,7 @@ export const DeckResults: React.FC = memo(() => {
)
)
:
(
<
div
className=
{
styles
.
empty
}
>
<
Loading
progress=
{
snap
.
progress
*
100
}
/>
<
Loading
/>
</
div
>
)
}
</>
...
...
@@ -174,16 +156,13 @@ const MdproDeckBlock: React.FC<{
);
};
const
updateMdproDeck
=
async
()
=>
{
const
resp
=
await
pullDecks
(
{
export
const
updateMdproDeck
=
async
()
=>
{
const
resp
=
await
pullDecks
({
page
:
store
.
page
,
size
:
PAGE_SIZE
,
keyWord
:
store
.
query
!==
""
?
store
.
query
:
undefined
,
sortLike
:
SORT_LIKE
,
},
updateProgress
,
);
});
if
(
resp
?.
data
)
{
const
{
total
,
records
:
newDecks
}
=
resp
.
data
;
...
...
@@ -193,19 +172,16 @@ const updateMdproDeck = async () => {
store
.
decks
=
[];
}
finish
Progress
();
finish
Loaded
();
};
const
updatePersonalList
=
async
(
message
:
MessageInstance
)
=>
{
const
user
=
accountStore
.
user
;
if
(
user
)
{
const
resp
=
await
getPersonalList
(
{
const
resp
=
await
getPersonalList
({
userID
:
user
.
id
,
token
:
user
.
token
,
},
updateProgress
,
);
});
if
(
resp
)
{
if
(
resp
.
code
!==
0
||
resp
.
data
===
undefined
)
{
...
...
@@ -249,12 +225,11 @@ const updatePersonalList = async (message: MessageInstance) => {
store
.
total
=
0
;
}
finish
Progress
();
finish
Loaded
();
};
const
resetProgress
=
()
=>
(
store
.
progress
=
0.01
);
const
updateProgress
=
(
progress
:
number
)
=>
(
store
.
progress
=
progress
*
0.9
);
const
finishProgress
=
()
=>
(
store
.
progress
=
1
);
const
resetLoaded
=
()
=>
(
store
.
loaded
=
false
);
const
finishLoaded
=
()
=>
(
store
.
loaded
=
true
);
const
copyMdproDeckToEditing
=
async
(
mdproDeck
:
MdproDeckLike
)
=>
{
// currently the content of the deck, which we named `Ydk`,
...
...
src/ui/Layout/index.tsx
View file @
395d59c3
...
...
@@ -28,6 +28,7 @@ import {
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
updateMdproDeck
}
from
"
../BuildDeck/DeckDatabase/DeckResults
"
;
import
{
setCssProperties
}
from
"
../Duel/PlayMat/css
"
;
import
{
Setting
}
from
"
../Setting
"
;
import
styles
from
"
./index.module.scss
"
;
...
...
@@ -52,6 +53,8 @@ export const loader: LoaderFunction = async () => {
initForbidden
();
initI18N
();
initSuper
();
// TODO: should avoid reloading mdpro deck again
updateMdproDeck
();
// set some styles
setCssProperties
();
...
...
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