feat: refactor sidebar to nested draggable lists with long-press gesture arbitration
This commit is contained in:
@@ -8,46 +8,21 @@ export interface SidebarShortcutWorkspaceTarget {
|
||||
workspaceId: string
|
||||
}
|
||||
|
||||
export type SidebarWorkspaceTreeRow =
|
||||
| {
|
||||
kind: 'project'
|
||||
rowKey: string
|
||||
project: SidebarProjectEntry
|
||||
displayName: string
|
||||
}
|
||||
| {
|
||||
kind: 'workspace'
|
||||
rowKey: string
|
||||
projectKey: string
|
||||
workspace: SidebarWorkspaceEntry
|
||||
shortcutNumber: number | null
|
||||
}
|
||||
|
||||
export interface SidebarWorkspaceViewModel {
|
||||
rows: SidebarWorkspaceTreeRow[]
|
||||
export interface SidebarShortcutModel {
|
||||
shortcutTargets: SidebarShortcutWorkspaceTarget[]
|
||||
shortcutIndexByWorkspaceKey: Map<string, number>
|
||||
}
|
||||
|
||||
export function buildSidebarWorkspaceViewModel(input: {
|
||||
export function buildSidebarShortcutModel(input: {
|
||||
projects: SidebarProjectEntry[]
|
||||
collapsedProjectKeys: ReadonlySet<string>
|
||||
getProjectDisplayName: (project: SidebarProjectEntry) => string
|
||||
shortcutLimit?: number
|
||||
}): SidebarWorkspaceViewModel {
|
||||
}): SidebarShortcutModel {
|
||||
const maxShortcuts = Math.max(0, Math.floor(input.shortcutLimit ?? 9))
|
||||
const rows: SidebarWorkspaceTreeRow[] = []
|
||||
const shortcutTargets: SidebarShortcutWorkspaceTarget[] = []
|
||||
const shortcutIndexByWorkspaceKey = new Map<string, number>()
|
||||
|
||||
for (const project of input.projects) {
|
||||
rows.push({
|
||||
kind: 'project',
|
||||
rowKey: `project:${project.projectKey}`,
|
||||
project,
|
||||
displayName: input.getProjectDisplayName(project),
|
||||
})
|
||||
|
||||
if (input.collapsedProjectKeys.has(project.projectKey)) {
|
||||
continue
|
||||
}
|
||||
@@ -62,16 +37,8 @@ export function buildSidebarWorkspaceViewModel(input: {
|
||||
})
|
||||
shortcutIndexByWorkspaceKey.set(workspace.workspaceKey, shortcutNumber)
|
||||
}
|
||||
|
||||
rows.push({
|
||||
kind: 'workspace',
|
||||
rowKey: `workspace:${project.projectKey}:${workspace.workspaceKey}`,
|
||||
projectKey: project.projectKey,
|
||||
workspace,
|
||||
shortcutNumber,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return { rows, shortcutTargets, shortcutIndexByWorkspaceKey }
|
||||
return { shortcutTargets, shortcutIndexByWorkspaceKey }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user