feat(desktop): add isSidecar prop to AppInterface and logic to persist sidecar server urls (#12366)
Co-authored-by: Brendan Allan <git@brendonovich.dev>
This commit is contained in:
@@ -28,7 +28,7 @@ function projectsKey(url: string) {
|
||||
|
||||
export const { use: useServer, provider: ServerProvider } = createSimpleContext({
|
||||
name: "Server",
|
||||
init: (props: { defaultUrl: string }) => {
|
||||
init: (props: { defaultUrl: string, isSidecar?: boolean }) => {
|
||||
const platform = usePlatform()
|
||||
|
||||
const [store, setStore, _, ready] = persisted(
|
||||
@@ -59,7 +59,13 @@ export const { use: useServer, provider: ServerProvider } = createSimpleContext(
|
||||
|
||||
const fallback = normalizeServerUrl(props.defaultUrl)
|
||||
if (fallback && url === fallback) {
|
||||
setState("active", url)
|
||||
batch(() => {
|
||||
if (!store.list.includes(url)) {
|
||||
// Add the fallback url to the list if it's not already in the list
|
||||
setStore("list", store.list.length, url)
|
||||
}
|
||||
setState("active", url)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -89,7 +95,17 @@ export const { use: useServer, provider: ServerProvider } = createSimpleContext(
|
||||
if (state.active) return
|
||||
const url = normalizeServerUrl(props.defaultUrl)
|
||||
if (!url) return
|
||||
setState("active", url)
|
||||
batch(() => {
|
||||
|
||||
// Add the new sidecar url
|
||||
if(props.isSidecar && props.defaultUrl) {
|
||||
add(props.defaultUrl)
|
||||
}
|
||||
|
||||
setState("active", url)
|
||||
})
|
||||
|
||||
console.log(store.list)
|
||||
})
|
||||
|
||||
const isReady = createMemo(() => ready() && !!state.active)
|
||||
|
||||
Reference in New Issue
Block a user