fixed application
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { useState } from 'react'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { NavLink, Link, useMatch } from 'react-router-dom'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { useAuth } from '../../contexts/AuthContext'
|
||||
import { useRecentRepos } from '../../hooks/useRecentRepos'
|
||||
import { useStarredRepos } from '../../hooks/useStarredRepos'
|
||||
import { useRepos } from '../../api/queries/repos'
|
||||
import { RepoAvatar } from '../../ui/RepoAvatar'
|
||||
|
||||
interface SidebarProps {
|
||||
@@ -12,10 +13,20 @@ interface SidebarProps {
|
||||
|
||||
export function Sidebar({ className }: SidebarProps) {
|
||||
const { user, isAuthenticated } = useAuth()
|
||||
const { repos: recentRepos } = useRecentRepos()
|
||||
const { repos: recentRepos, remove } = useRecentRepos()
|
||||
const { toggle, isStarred } = useStarredRepos()
|
||||
const { data: apiRepos } = useRepos()
|
||||
const [openRecent, setOpenRecent] = useState(true)
|
||||
|
||||
// Drop localStorage entries for repos that no longer exist in the API.
|
||||
useEffect(() => {
|
||||
if (!apiRepos) return
|
||||
const existing = new Set(apiRepos.map(r => `${r.ownerName}/${r.name}`))
|
||||
recentRepos.forEach(r => {
|
||||
if (!existing.has(`${r.ownerName}/${r.name}`)) remove(r.ownerName, r.name)
|
||||
})
|
||||
}, [apiRepos])
|
||||
|
||||
// Detect if we're inside a repo
|
||||
const repoMatch = useMatch('/repos/:owner/:repo/*')
|
||||
const currentOwner = repoMatch?.params.owner
|
||||
|
||||
Reference in New Issue
Block a user