mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(frontend): order linked server projects by last activity and keep cached lists on refetch errors
This commit is contained in:
1 parent
578a2211ba
commit
36d35cc974
5 files changed
+185
-22
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { listProjects, type OpenCodeProject } from '@/api/opencode'
|
||||
import { listProjects, projectActivityTimestamp, type OpenCodeProject } from '@/api/opencode'
|
||||
import type { Session } from '@/api/types'
|
||||
import { ActivityStateIndicator } from '@/components/activity/ActivityStateIndicator'
|
||||
import { useSessionsAcrossDirectories, sessionQueryOptions } from '@/hooks/useOpenCode'
|
||||
@@ -393,14 +393,20 @@ export function RemoteProjectNavList({
|
||||
retry: false,
|
||||
})
|
||||
|
||||
const projects = useMemo(() => projectsQuery.data ?? [], [projectsQuery.data])
|
||||
const projects = useMemo(
|
||||
() =>
|
||||
[...(projectsQuery.data ?? [])].sort(
|
||||
(a, b) => projectActivityTimestamp(b) - projectActivityTimestamp(a),
|
||||
),
|
||||
[projectsQuery.data],
|
||||
)
|
||||
const trimmedSearch = search.trim()
|
||||
|
||||
if (isServersLoading) return <SessionNavStatus>Loading projects...</SessionNavStatus>
|
||||
if (!server) return <SessionNavStatus>Server not found</SessionNavStatus>
|
||||
if (!server.enabled) return <SessionNavStatus>Server is disabled</SessionNavStatus>
|
||||
if (projectsQuery.isLoading) return <SessionNavStatus>Loading projects...</SessionNavStatus>
|
||||
if (projectsQuery.isError) {
|
||||
if (projectsQuery.isError && projectsQuery.data === undefined) {
|
||||
return (
|
||||
<SessionNavStatus>
|
||||
{statusById[serverId]?.connected === false ? 'Server unreachable' : 'Could not load projects'}
|
||||
|
||||
Reference in new issue
Block a user