fix(app): persist workspace order and collapsed state
This commit is contained in:
@@ -64,7 +64,7 @@ import { useServer } from "@/context/server"
|
|||||||
|
|
||||||
export default function Layout(props: ParentProps) {
|
export default function Layout(props: ParentProps) {
|
||||||
const [store, setStore, , ready] = persisted(
|
const [store, setStore, , ready] = persisted(
|
||||||
Persist.global("layout", ["layout.v6"]),
|
Persist.global("layout.page", ["layout.page.v1"]),
|
||||||
createStore({
|
createStore({
|
||||||
lastSession: {} as { [directory: string]: string },
|
lastSession: {} as { [directory: string]: string },
|
||||||
activeProject: undefined as string | undefined,
|
activeProject: undefined as string | undefined,
|
||||||
@@ -74,6 +74,9 @@ export default function Layout(props: ParentProps) {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const pageReady = createMemo(() => ready())
|
||||||
|
const layoutReady = createMemo(() => layout.ready())
|
||||||
|
|
||||||
let scrollContainerRef: HTMLDivElement | undefined
|
let scrollContainerRef: HTMLDivElement | undefined
|
||||||
const xlQuery = window.matchMedia("(min-width: 1280px)")
|
const xlQuery = window.matchMedia("(min-width: 1280px)")
|
||||||
const [isLargeViewport, setIsLargeViewport] = createSignal(xlQuery.matches)
|
const [isLargeViewport, setIsLargeViewport] = createSignal(xlQuery.matches)
|
||||||
@@ -293,7 +296,8 @@ export default function Layout(props: ParentProps) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (!ready()) return
|
if (!pageReady()) return
|
||||||
|
if (!layoutReady()) return
|
||||||
const project = currentProject()
|
const project = currentProject()
|
||||||
if (!project) return
|
if (!project) return
|
||||||
|
|
||||||
@@ -318,6 +322,16 @@ export default function Layout(props: ParentProps) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
if (!pageReady()) return
|
||||||
|
if (!layoutReady()) return
|
||||||
|
for (const [directory, expanded] of Object.entries(store.workspaceExpanded)) {
|
||||||
|
if (layout.sidebar.workspaces(directory)()) continue
|
||||||
|
if (!expanded) continue
|
||||||
|
setStore("workspaceExpanded", directory, false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const currentSessions = createMemo(() => {
|
const currentSessions = createMemo(() => {
|
||||||
const project = currentProject()
|
const project = currentProject()
|
||||||
if (!project) return [] as Session[]
|
if (!project) return [] as Session[]
|
||||||
@@ -708,6 +722,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
if (!pageReady()) return
|
||||||
if (!params.dir || !params.id) return
|
if (!params.dir || !params.id) return
|
||||||
const directory = base64Decode(params.dir)
|
const directory = base64Decode(params.dir)
|
||||||
const id = params.id
|
const id = params.id
|
||||||
|
|||||||
Reference in New Issue
Block a user