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:
parent
b12eab782f
commit
687210a55d
3 changed files with 24 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue