app: deduplicate allServers list
This commit is contained in:
@@ -427,6 +427,7 @@ export function DialogSelectServer() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{(i) => {
|
{(i) => {
|
||||||
|
const key = ServerConnection.key(i)
|
||||||
return (
|
return (
|
||||||
<div class="flex items-center gap-3 min-w-0 flex-1 group/item">
|
<div class="flex items-center gap-3 min-w-0 flex-1 group/item">
|
||||||
<Show
|
<Show
|
||||||
@@ -446,8 +447,8 @@ export function DialogSelectServer() {
|
|||||||
>
|
>
|
||||||
<ServerRow
|
<ServerRow
|
||||||
conn={i}
|
conn={i}
|
||||||
status={store.status[ServerConnection.key(i)]}
|
status={store.status[key]}
|
||||||
dimmed={store.status[ServerConnection.key(i)]?.healthy === false}
|
dimmed={store.status[key]?.healthy === false}
|
||||||
class="flex items-center gap-3 px-4 min-w-0 flex-1"
|
class="flex items-center gap-3 px-4 min-w-0 flex-1"
|
||||||
badge={
|
badge={
|
||||||
<Show when={defaultUrl() === i.http.url}>
|
<Show when={defaultUrl() === i.http.url}>
|
||||||
@@ -460,7 +461,7 @@ export function DialogSelectServer() {
|
|||||||
</Show>
|
</Show>
|
||||||
<Show when={store.editServer.id !== i.http.url}>
|
<Show when={store.editServer.id !== i.http.url}>
|
||||||
<div class="flex items-center justify-center gap-5 pl-4">
|
<div class="flex items-center justify-center gap-5 pl-4">
|
||||||
<Show when={current() === i}>
|
<Show when={ServerConnection.key(current()) === key}>
|
||||||
<p class="text-text-weak text-12-regular">{language.t("dialog.server.current")}</p>
|
<p class="text-text-weak text-12-regular">{language.t("dialog.server.current")}</p>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
|
|||||||
@@ -102,15 +102,19 @@ export const { use: useServer, provider: ServerProvider } = createSimpleContext(
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const allServers = createMemo(
|
const allServers = createMemo((): Array<ServerConnection.Any> => {
|
||||||
(): Array<ServerConnection.Any> => [
|
const servers = [
|
||||||
...(props.servers ?? []),
|
...(props.servers ?? []),
|
||||||
...store.list.map((value) => ({
|
...store.list.map((value) => ({
|
||||||
type: "http" as const,
|
type: "http" as const,
|
||||||
http: typeof value === "string" ? { url: value } : value,
|
http: typeof value === "string" ? { url: value } : value,
|
||||||
})),
|
})),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
const deduped = new Map(servers.map((conn) => [ServerConnection.key(conn), conn]))
|
||||||
|
|
||||||
|
return [...deduped.values()]
|
||||||
|
})
|
||||||
|
|
||||||
const [state, setState] = createStore({
|
const [state, setState] = createStore({
|
||||||
active: props.defaultServer,
|
active: props.defaultServer,
|
||||||
|
|||||||
Reference in New Issue
Block a user