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
e3201846
Commit
e3201846
authored
Jun 22, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add progress for loading mdpro deck
parent
755b5d03
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
113 additions
and
52 deletions
+113
-52
src/api/mdproDeck/personalList.ts
src/api/mdproDeck/personalList.ts
+9
-4
src/api/mdproDeck/pull.ts
src/api/mdproDeck/pull.ts
+9
-4
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
+67
-44
src/ui/I18N/Source/Brazilian/translation.json
src/ui/I18N/Source/Brazilian/translation.json
+3
-0
src/ui/I18N/Source/Chinese/translation.json
src/ui/I18N/Source/Chinese/translation.json
+3
-0
src/ui/I18N/Source/English/translation.json
src/ui/I18N/Source/English/translation.json
+3
-0
src/ui/I18N/Source/French/translation.json
src/ui/I18N/Source/French/translation.json
+3
-0
src/ui/I18N/Source/Japanese/translation.json
src/ui/I18N/Source/Japanese/translation.json
+3
-0
src/ui/I18N/Source/Portuguese/translation.json
src/ui/I18N/Source/Portuguese/translation.json
+3
-0
src/ui/I18N/Source/Spanish/translation.json
src/ui/I18N/Source/Spanish/translation.json
+3
-0
src/ui/I18N/index.ts
src/ui/I18N/index.ts
+7
-0
No files found.
src/api/mdproDeck/personalList.ts
View file @
e3201846
import
{
useConfig
}
from
"
@/config
"
;
import
{
pfetch
}
from
"
@/infra
"
;
import
{
MdproDeck
,
MdproResp
}
from
"
./schema
"
;
import
{
handleHttps
,
mdproHeaders
}
from
"
./util
"
;
...
...
@@ -15,14 +16,18 @@ export interface PersonalListReq {
export
async
function
getPersonalList
(
req
:
PersonalListReq
,
progressCallback
?:
(
progress
:
number
)
=>
void
,
):
Promise
<
MdproResp
<
MdproDeck
[]
>
|
undefined
>
{
const
myHeaders
=
mdproHeaders
();
myHeaders
.
append
(
"
token
"
,
req
.
token
);
const
resp
=
await
fetch
(
`
${
mdproServer
}
/
${
API_PATH
}
/
${
req
.
userID
}
`
,
{
const
resp
=
await
pfetch
(
`
${
mdproServer
}
/
${
API_PATH
}
/
${
req
.
userID
}
`
,
{
init
:
{
method
:
"
GET
"
,
headers
:
myHeaders
,
redirect
:
"
follow
"
,
},
progressCallback
,
});
return
await
handleHttps
(
resp
,
API_PATH
);
...
...
src/api/mdproDeck/pull.ts
View file @
e3201846
import
{
useConfig
}
from
"
@/config
"
;
import
{
pfetch
}
from
"
@/infra
"
;
import
{
MdproDeckLike
,
MdproResp
}
from
"
./schema
"
;
import
{
handleHttps
,
mdproHeaders
}
from
"
./util
"
;
...
...
@@ -30,6 +31,7 @@ interface RespData {
export
async
function
pullDecks
(
req
:
PullReq
=
defaultPullReq
,
progressCallback
?:
(
progress
:
number
)
=>
void
,
):
Promise
<
MdproResp
<
RespData
>
|
undefined
>
{
const
myHeaders
=
mdproHeaders
();
...
...
@@ -43,10 +45,13 @@ export async function pullDecks(
const
url
=
new
URL
(
`
${
mdproServer
}
/
${
API_PATH
}
`
);
url
.
search
=
params
.
toString
();
const
resp
=
await
fetch
(
url
.
toString
(),
{
const
resp
=
await
pfetch
(
url
.
toString
(),
{
init
:
{
method
:
"
GET
"
,
headers
:
myHeaders
,
redirect
:
"
follow
"
,
},
progressCallback
,
});
return
await
handleHttps
(
resp
,
API_PATH
);
...
...
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
View file @
e3201846
...
...
@@ -10,7 +10,7 @@ import { deleteDeck, getPersonalList, mgetDeck, pullDecks } from "@/api";
import
{
MdproDeckLike
}
from
"
@/api/mdproDeck/schema
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
IconFont
}
from
"
@/ui/Shared
"
;
import
{
IconFont
,
Loading
}
from
"
@/ui/Shared
"
;
import
{
setSelectedDeck
}
from
"
../..
"
;
import
{
editDeckStore
}
from
"
../../store
"
;
...
...
@@ -25,6 +25,7 @@ interface Props {
decks
:
MdproDeckLike
[];
total
:
number
;
onlyMine
:
boolean
;
progress
:
number
;
}
// TODO: useConfig
...
...
@@ -37,6 +38,7 @@ const store = proxy<Props>({
decks
:
[],
total
:
0
,
onlyMine
:
false
,
progress
:
0.01
,
});
export
const
DeckResults
:
React
.
FC
=
memo
(()
=>
{
...
...
@@ -44,29 +46,13 @@ export const DeckResults: React.FC = memo(() => {
const
{
message
}
=
App
.
useApp
();
const
{
t
:
i18n
}
=
useTranslation
(
"
DeckResults
"
);
useEffect
(()
=>
{
resetProgress
();
if
(
snap
.
onlyMine
)
{
// show only decks uploaded by myself
updatePersonalList
(
message
);
}
else
{
const
update
=
async
()
=>
{
const
resp
=
await
pullDecks
({
page
:
snap
.
page
,
size
:
PAGE_SIZE
,
keyWord
:
snap
.
query
!==
""
?
snap
.
query
:
undefined
,
sortLike
:
SORT_LIKE
,
});
if
(
resp
?.
data
)
{
const
{
total
,
records
:
newDecks
}
=
resp
.
data
;
store
.
total
=
total
;
store
.
decks
=
newDecks
;
}
else
{
store
.
decks
=
[];
}
};
update
();
updateMdproDeck
();
}
},
[
snap
.
query
,
snap
.
page
,
snap
.
onlyMine
]);
...
...
@@ -92,7 +78,8 @@ export const DeckResults: React.FC = memo(() => {
return
(
<>
{
snap
.
decks
.
length
?
(
{
snap
.
progress
===
1
?
(
snap
.
decks
.
length
?
(
<
div
className=
{
styles
.
container
}
>
<
div
className=
{
styles
[
"
search-decks
"
]
}
>
{
snap
.
decks
.
map
((
deck
)
=>
(
...
...
@@ -119,6 +106,11 @@ export const DeckResults: React.FC = memo(() => {
<
IconFont
type=
"icon-empty"
size=
{
40
}
/>
<
div
>
{
i18n
(
"
NoDeckGroupFound
"
)
}
</
div
>
</
div
>
)
)
:
(
<
div
className=
{
styles
.
empty
}
>
<
Loading
progress=
{
snap
.
progress
*
100
}
/>
</
div
>
)
}
</>
);
...
...
@@ -182,13 +174,38 @@ const MdproDeckBlock: React.FC<{
);
};
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
;
store
.
total
=
total
;
store
.
decks
=
newDecks
;
}
else
{
store
.
decks
=
[];
}
finishProgress
();
};
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
)
{
...
...
@@ -231,8 +248,14 @@ const updatePersonalList = async (message: MessageInstance) => {
store
.
decks
=
[];
store
.
total
=
0
;
}
finishProgress
();
};
const
resetProgress
=
()
=>
(
store
.
progress
=
0.01
);
const
updateProgress
=
(
progress
:
number
)
=>
(
store
.
progress
=
progress
*
0.9
);
const
finishProgress
=
()
=>
(
store
.
progress
=
1
);
const
copyMdproDeckToEditing
=
async
(
mdproDeck
:
MdproDeckLike
)
=>
{
// currently the content of the deck, which we named `Ydk`,
// haven't been downloaded, so we need to fetch from server again by `mgetDeck`
...
...
src/ui/I18N/Source/Brazilian/translation.json
View file @
e3201846
...
...
@@ -198,5 +198,8 @@
"TurnOnSoundEffects"
:
"Efeitos sonoros"
,
"SwitchMusicAccordingToTheEnvironment"
:
"Trocar música conforme o ambiente"
,
"LanguageSettings"
:
"Idioma"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"Não foi possível encontrar o baralho correspondente"
}
}
src/ui/I18N/Source/Chinese/translation.json
View file @
e3201846
...
...
@@ -200,5 +200,8 @@
"TurnOnSoundEffects"
:
"开启音效"
,
"SwitchMusicAccordingToTheEnvironment"
:
"根据环境切换音乐"
,
"LanguageSettings"
:
"语言"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"找不到相应卡组"
}
}
src/ui/I18N/Source/English/translation.json
View file @
e3201846
...
...
@@ -200,5 +200,8 @@
"TurnOnSoundEffects"
:
"Sound effects"
,
"SwitchMusicAccordingToTheEnvironment"
:
"Switch music according to the environment"
,
"LanguageSettings"
:
"Language"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"Cannot find the corresponding card deck"
}
}
src/ui/I18N/Source/French/translation.json
View file @
e3201846
...
...
@@ -198,5 +198,8 @@
"TurnOnSoundEffects"
:
"Effets sonores"
,
"SwitchMusicAccordingToTheEnvironment"
:
"Changer la musique en fonction de l'environnement"
,
"LanguageSettings"
:
"Langue"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"Impossible de trouver le jeu de cartes correspondant"
}
}
src/ui/I18N/Source/Japanese/translation.json
View file @
e3201846
...
...
@@ -198,5 +198,8 @@
"TurnOnSoundEffects"
:
"効果音をオンにする"
,
"SwitchMusicAccordingToTheEnvironment"
:
"環境に応じて音楽を切り替える"
,
"LanguageSettings"
:
"言語"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"対応するカードデッキが見つかりません"
}
}
src/ui/I18N/Source/Portuguese/translation.json
View file @
e3201846
...
...
@@ -197,5 +197,8 @@
"TurnOnMusic"
:
"Música"
,
"TurnOnSoundEffects"
:
"Efeitos sonoros"
,
"SwitchMusicAccordingToTheEnvironment"
:
"Trocar música conforme o ambiente"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"Não foi possível encontrar o baralho correspondente"
}
}
src/ui/I18N/Source/Spanish/translation.json
View file @
e3201846
...
...
@@ -198,5 +198,8 @@
"TurnOnSoundEffects"
:
"Efectos de sonido"
,
"SwitchMusicAccordingToTheEnvironment"
:
"Cambiar la música según el entorno"
,
"LanguageSettings"
:
"Idioma"
},
"DeckResults"
:
{
"NoDeckGroupFound"
:
"No se puede encontrar el mazo de cartas correspondiente"
}
}
src/ui/I18N/index.ts
View file @
e3201846
...
...
@@ -32,6 +32,7 @@ const resources = {
Menu
:
translationChinese
.
Menu
,
SelectCardModal
:
translationChinese
.
SelectCardModal
,
SystemSettings
:
translationChinese
.
SystemSettings
,
DeckResults
:
translationChinese
.
DeckResults
,
},
en
:
{
Header
:
translationEnglish
.
Header
,
...
...
@@ -51,6 +52,7 @@ const resources = {
Menu
:
translationEnglish
.
Menu
,
SelectCardModal
:
translationEnglish
.
SelectCardModal
,
SystemSettings
:
translationEnglish
.
SystemSettings
,
DeckResults
:
translationEnglish
.
DeckResults
,
},
es
:
{
Header
:
translationSpanish
.
Header
,
...
...
@@ -70,6 +72,7 @@ const resources = {
Menu
:
translationSpanish
.
Menu
,
SelectCardModal
:
translationSpanish
.
SelectCardModal
,
SystemSettings
:
translationSpanish
.
SystemSettings
,
DeckResults
:
translationSpanish
.
DeckResults
,
},
fr
:
{
Header
:
translationFrench
.
Header
,
...
...
@@ -89,6 +92,7 @@ const resources = {
Menu
:
translationFrench
.
Menu
,
SelectCardModal
:
translationFrench
.
SelectCardModal
,
SystemSettings
:
translationFrench
.
SystemSettings
,
DeckResults
:
translationFrench
.
DeckResults
,
},
ja
:
{
Header
:
translationJapanese
.
Header
,
...
...
@@ -108,6 +112,7 @@ const resources = {
Menu
:
translationJapanese
.
Menu
,
SelectCardModal
:
translationJapanese
.
SelectCardModal
,
SystemSettings
:
translationJapanese
.
SystemSettings
,
DeckResults
:
translationJapanese
.
DeckResults
,
},
br
:
{
Header
:
translationBrazilian
.
Header
,
...
...
@@ -127,6 +132,7 @@ const resources = {
Menu
:
translationBrazilian
.
Menu
,
SelectCardModal
:
translationBrazilian
.
SelectCardModal
,
SystemSettings
:
translationBrazilian
.
SystemSettings
,
DeckResults
:
translationBrazilian
.
DeckResults
,
},
pt
:
{
Header
:
translationPortuguese
.
Header
,
...
...
@@ -146,6 +152,7 @@ const resources = {
Menu
:
translationPortuguese
.
Menu
,
SelectCardModal
:
translationPortuguese
.
SelectCardModal
,
SystemSettings
:
translationPortuguese
.
SystemSettings
,
DeckResults
:
translationPortuguese
.
DeckResults
,
},
};
...
...
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