This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import axios from 'axios'
|
||||
import toCamel from 'camelcase-keys'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { Link, useLocation, /* useNavigate */ } from 'react-router-dom'
|
||||
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
|
||||
import { cn } from '@/lib/utils'
|
||||
@@ -22,7 +21,7 @@ type Menu = typeof Menu[keyof typeof Menu]
|
||||
|
||||
export default ({ user }: Props) => {
|
||||
const location = useLocation ()
|
||||
const navigate = useNavigate ()
|
||||
// const navigate = useNavigate ()
|
||||
|
||||
const [selectedMenu, setSelectedMenu] = useState<Menu> (Menu.None)
|
||||
const [wikiId, setWikiId] = useState<number | null> (WikiIdBus.get ())
|
||||
@@ -116,14 +115,14 @@ export default ({ user }: Props) => {
|
||||
if (!(wikiId))
|
||||
return
|
||||
|
||||
void (async () => {
|
||||
const fetchPostCount = async () => {
|
||||
try
|
||||
{
|
||||
const pageRes = await axios.get (`${ API_BASE_URL }/wiki/${ wikiId }`)
|
||||
const wikiPage = toCamel (pageRes.data as any, { deep: true }) as WikiPage
|
||||
|
||||
const tagRes = await axios.get (`${ API_BASE_URL }/tags/name/${ wikiPage.title }`)
|
||||
const tag = toCamel (tagData, { deep: true }) as Tag
|
||||
const tag = toCamel (tagRes.data as any, { deep: true }) as Tag
|
||||
|
||||
setPostCount (tag.postCount)
|
||||
}
|
||||
@@ -131,7 +130,8 @@ export default ({ user }: Props) => {
|
||||
{
|
||||
setPostCount (0)
|
||||
}
|
||||
}) ()
|
||||
}
|
||||
fetchPostCount ()
|
||||
}, [wikiId])
|
||||
|
||||
return (
|
||||
|
||||
@@ -58,7 +58,7 @@ export default ({ user }: Props) => {
|
||||
'X-Transfer-Code': localStorage.getItem ('user_code') ?? '' } })
|
||||
const data = toCamel (res.data as any, { deep: true }) as Tag[]
|
||||
setNicoTags (nicoTags => {
|
||||
nicoTags.find (t => t.id === id).linkedTags = data
|
||||
nicoTags.find (t => t.id === id)!.linkedTags = data
|
||||
return [...nicoTags]
|
||||
})
|
||||
setRawTags (rawTags => ({ ...rawTags, [id]: data.map (t => t.name).join (' ') }))
|
||||
|
||||
Reference in New Issue
Block a user