fix: fixed how operator updated status is handled
This commit is contained in:
@@ -11,20 +11,21 @@
|
||||
"lint:fix": "biome check --write ."
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"jotai": "^2.15.0",
|
||||
"react-router-dom": "^7.9.3",
|
||||
"react-simple-typewriter": "^5.0.1",
|
||||
"reset-css": "^5.0.2",
|
||||
"@aklive2d/postcss-config": "workspace:*",
|
||||
"@aklive2d/assets": "workspace:*",
|
||||
"@aklive2d/config": "workspace:*",
|
||||
"@aklive2d/libs": "workspace:*",
|
||||
"@aklive2d/assets": "workspace:*",
|
||||
"@aklive2d/module": "workspace:*",
|
||||
"@aklive2d/operator": "workspace:*",
|
||||
"@aklive2d/vite-helpers": "workspace:*",
|
||||
"@aklive2d/postcss-config": "workspace:*",
|
||||
"@aklive2d/showcase": "workspace:*",
|
||||
"@aklive2d/module": "workspace:*"
|
||||
"@aklive2d/vite-helpers": "workspace:*",
|
||||
"jotai": "^2.15.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-router-dom": "^7.9.3",
|
||||
"react-simple-typewriter": "^5.0.1",
|
||||
"reset-css": "^5.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=5.9.3"
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function Home() {
|
||||
const _trackEvt = useInsight()
|
||||
const { setTitle, setTabs, currentTab, setHeaderIcon, setFastNavigation } =
|
||||
useHeader()
|
||||
const { config, operators, officialUpdate } = useConfig()
|
||||
const { config, operators, newOperators } = useConfig()
|
||||
const { i18n } = useI18n()
|
||||
const [content, setContent] = useState([])
|
||||
const [voiceOn] = useAtom(voiceOnAtom)
|
||||
@@ -174,7 +174,7 @@ export default function Home() {
|
||||
|
||||
return (
|
||||
<section>
|
||||
{officialUpdate.length > operators.length && (
|
||||
{newOperators.length > 0 && (
|
||||
<section>
|
||||
<section
|
||||
className={`${classes['official-update']} ${classes.group}`}
|
||||
@@ -182,30 +182,17 @@ export default function Home() {
|
||||
<section className={classes.info}>
|
||||
<section className={classes.content}>
|
||||
<section className={classes.text}>
|
||||
{officialUpdate.length - operators.length}{' '}
|
||||
{i18n('new_op_wait_to_update')}
|
||||
{`${newOperators.length} ${i18n('new_op_wait_to_update')}`}
|
||||
</section>
|
||||
<section
|
||||
className={`${classes['styled-selection']}`}
|
||||
>
|
||||
{officialUpdate.info
|
||||
.filter(
|
||||
(e) =>
|
||||
!operators.find(
|
||||
(o) =>
|
||||
o.official_id ===
|
||||
e.id.toString()
|
||||
)
|
||||
)
|
||||
.map((entry, index) => {
|
||||
{newOperators.map((entry, index) => {
|
||||
return (
|
||||
<Link
|
||||
reloadDocument
|
||||
to={entry.link}
|
||||
target="_blank"
|
||||
style={{
|
||||
color: entry.color,
|
||||
}}
|
||||
key={index}
|
||||
>
|
||||
<section
|
||||
@@ -301,7 +288,7 @@ export default function Home() {
|
||||
</section>
|
||||
</section>
|
||||
<section className={classes.date}>
|
||||
{officialUpdate.latest}
|
||||
{newOperators[0].date}
|
||||
</section>
|
||||
</section>
|
||||
<Border />
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import CONFIG from '!/config.json'
|
||||
import { atom, useAtom } from 'jotai'
|
||||
import { difference } from 'lodash-es'
|
||||
import { useCallback } from 'react'
|
||||
|
||||
const officialUpdateAtom = atom({})
|
||||
let operators = []
|
||||
CONFIG.operators.forEach((item) => {
|
||||
operators = [...operators, ...item]
|
||||
})
|
||||
const OPERATORS = operators
|
||||
const newOperatorsAtom = atom({})
|
||||
const OPERATORS = CONFIG.operators.flat()
|
||||
|
||||
export function useConfig() {
|
||||
const config = CONFIG
|
||||
const operators = OPERATORS
|
||||
const [officialUpdate, setOfficialUpdate] = useAtom(officialUpdateAtom)
|
||||
const [newOperators, setNewOperators] = useAtom(newOperatorsAtom)
|
||||
|
||||
const fetchOfficialUpdate = useCallback(async () => {
|
||||
const res = await fetch(
|
||||
@@ -24,8 +21,11 @@ export function useConfig() {
|
||||
length: 0,
|
||||
}
|
||||
})
|
||||
setOfficialUpdate(data)
|
||||
}, [setOfficialUpdate])
|
||||
const compiledIds = operators.map((item) => item.official_id.toString())
|
||||
const updatedIds = data.info.map((item) => item.id.toString())
|
||||
const newIds = difference(updatedIds, compiledIds)
|
||||
setNewOperators(data.info.filter((item) => newIds.includes(item.id.toString())))
|
||||
}, [])
|
||||
|
||||
return { config, operators, officialUpdate, fetchOfficialUpdate }
|
||||
return { config, operators, newOperators, fetchOfficialUpdate }
|
||||
}
|
||||
|
||||
3
bun.lock
3
bun.lock
@@ -24,6 +24,7 @@
|
||||
"@aklive2d/showcase": "workspace:*",
|
||||
"@aklive2d/vite-helpers": "workspace:*",
|
||||
"jotai": "^2.15.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-router-dom": "^7.9.3",
|
||||
@@ -816,6 +817,8 @@
|
||||
|
||||
"lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="],
|
||||
|
||||
"lodash-es": ["lodash-es@4.17.21", "", {}, "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="],
|
||||
|
||||
"lodash.isplainobject": ["lodash.isplainobject@4.0.6", "", {}, "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="],
|
||||
|
||||
"lodash.map": ["lodash.map@4.6.0", "", {}, "sha512-worNHGKLDetmcEYDvh2stPCrrQRkP20E4l0iIS7F8EvzMqBBi7ltvFN5m1HvTf1P7Jk1txKhvFcmYsCr8O2F1Q=="],
|
||||
|
||||
Reference in New Issue
Block a user