feat: Wiki 有無判定軽量化(#233) (#234)
#233 Backend が対応できてなかったのでそっちも対応させた. Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #234
This commit was merged in pull request #234.
This commit is contained in:
@@ -32,7 +32,15 @@ export default (({ tag,
|
||||
...props }: Props) => {
|
||||
const [havingWiki, setHavingWiki] = useState (true)
|
||||
|
||||
const wikiExists = async (tagName: string) => {
|
||||
const wikiExists = async (tag: Tag) => {
|
||||
if ('hasWiki' in tag)
|
||||
{
|
||||
setHavingWiki (tag.hasWiki)
|
||||
return
|
||||
}
|
||||
|
||||
const tagName = (tag as Tag).name
|
||||
|
||||
try
|
||||
{
|
||||
await axios.get (`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (tagName) }/exists`)
|
||||
@@ -48,7 +56,7 @@ export default (({ tag,
|
||||
if (!(linkFlg) || !(withWiki))
|
||||
return
|
||||
|
||||
wikiExists (tag.name)
|
||||
wikiExists (tag)
|
||||
}, [tag.name, linkFlg, withWiki])
|
||||
|
||||
const spanClass = cn (
|
||||
|
||||
@@ -48,6 +48,7 @@ export type Tag = {
|
||||
name: string
|
||||
category: Category
|
||||
postCount: number
|
||||
hasWiki: boolean
|
||||
children?: Tag[] }
|
||||
|
||||
export type User = {
|
||||
|
||||
Reference in New Issue
Block a user