|
111 | 111 | const branchName = $derived(selection.current?.branchName);
|
112 | 112 | const upstream = $derived(selection.current?.upstream);
|
113 | 113 |
|
114 |
| - const selectedLastAdded = $derived.by(() => { |
| 114 | + const activeSelectionId: SelectionId | undefined = $derived.by(() => { |
115 | 115 | if (commitId) {
|
116 |
| - return idSelection.getById({ type: 'commit', commitId, stackId: stack.id }).lastAdded; |
| 116 | + return { type: 'commit', commitId, stackId: stack.id }; |
117 | 117 | } else if (branchName) {
|
118 |
| - return idSelection.getById({ type: 'branch', stackId: stack.id, branchName }).lastAdded; |
| 118 | + return { type: 'branch', stackId: stack.id, branchName }; |
119 | 119 | }
|
120 | 120 | });
|
121 | 121 |
|
122 |
| - const selectedKey = $derived( |
123 |
| - $selectedLastAdded?.key ? readKey($selectedLastAdded.key) : undefined |
124 |
| - ); |
| 122 | + const activeLastAdded = $derived.by(() => { |
| 123 | + if (activeSelectionId) { |
| 124 | + return idSelection.getById(activeSelectionId).lastAdded; |
| 125 | + } |
| 126 | + }); |
125 | 127 |
|
126 |
| - const previewKey = $derived(assignedKey || selectedKey); |
| 128 | + const selectedFile = $derived($activeLastAdded?.key ? readKey($activeLastAdded.key) : undefined); |
| 129 | +
|
| 130 | + const previewKey = $derived(assignedKey || selectedFile); |
127 | 131 | const previewChangeResult = $derived(
|
128 | 132 | previewKey ? idSelection.changeByKey(projectId, previewKey) : undefined
|
129 | 133 | );
|
|
282 | 286 | stackId={stack.id}
|
283 | 287 | {projectId}
|
284 | 288 | {branchName}
|
285 |
| - active={selectedKey?.type === 'branch' && |
286 |
| - selectedKey.branchName === branchName && |
| 289 | + active={selectedFile?.type === 'branch' && |
| 290 | + selectedFile.branchName === branchName && |
287 | 291 | focusedStackId === stack.id}
|
288 | 292 | scrollToType="details"
|
289 | 293 | scrollToId={stack.id}
|
|
304 | 308 | upstream: !!upstream
|
305 | 309 | }}
|
306 | 310 | draggableFiles
|
307 |
| - active={selectedKey?.type === 'commit' && focusedStackId === stack.id} |
| 311 | + active={selectedFile?.type === 'commit' && focusedStackId === stack.id} |
308 | 312 | scrollToType="details"
|
309 | 313 | scrollToId={stack.id}
|
310 | 314 | bind:clientHeight={actualDetailsHeight}
|
|
314 | 318 | {/snippet}
|
315 | 319 |
|
316 | 320 | {#snippet commitChangedFiles(commitId: string)}
|
317 |
| - {@const active = selectedKey?.type === 'commit' && focusedStackId === stack.id} |
| 321 | + {@const active = activeSelectionId?.type === 'commit' && focusedStackId === stack.id} |
318 | 322 | {@const changesResult = stackService.commitChanges(projectId, commitId)}
|
319 | 323 | <ReduxResult {projectId} stackId={stack.id} result={changesResult.current}>
|
320 | 324 | {#snippet children(changes, { projectId, stackId })}
|
|
349 | 353 | {/snippet}
|
350 | 354 |
|
351 | 355 | {#snippet branchChangedFiles(branchName: string)}
|
352 |
| - {@const active = selectedKey?.type === 'branch' && focusedStackId === stack.id} |
| 356 | + {@const active = activeSelectionId?.type === 'branch' && focusedStackId === stack.id} |
353 | 357 | {@const changesResult = stackService.branchChanges({
|
354 | 358 | projectId,
|
355 | 359 | stackId: stack.id,
|
|
362 | 366 | {projectId}
|
363 | 367 | {stackId}
|
364 | 368 | draggableFiles
|
| 369 | + autoselect |
365 | 370 | selectionId={{ type: 'branch', stackId: stack.id, branchName }}
|
366 | 371 | noshrink={!!previewKey}
|
367 | 372 | ontoggle={() => {
|
|
513 | 518 | </ReduxResult>
|
514 | 519 | </div>
|
515 | 520 |
|
516 |
| - {#if commitId || branchName || assignedKey || selectedKey} |
| 521 | + {#if commitId || branchName || assignedKey || selectedFile} |
517 | 522 | <div
|
518 | 523 | class="combined-view"
|
519 | 524 | bind:this={compactDiv}
|
|
529 | 534 | {@render branchChangedFiles(branchName)}
|
530 | 535 | {/if}
|
531 | 536 |
|
532 |
| - {#if assignedKey || selectedKey} |
| 537 | + {#if assignedKey || selectedFile} |
533 | 538 | <ReduxResult {projectId} result={previewChangeResult?.current}>
|
534 | 539 | {#snippet children(previewChange)}
|
535 | 540 | {@const diffResult = diffService.getDiff(projectId, previewChange)}
|
|
539 | 544 | <ConfigurableScrollableContainer zIndex="var(--z-lifted)">
|
540 | 545 | {@render assignedChangePreview(assignedKey.stackId)}
|
541 | 546 | </ConfigurableScrollableContainer>
|
542 |
| - {:else if selectedKey} |
| 547 | + {:else if selectedFile} |
543 | 548 | <Drawer bottomBorder>
|
544 | 549 | {#snippet header()}
|
545 | 550 | <FileViewHeader
|
|
555 | 560 | : undefined}
|
556 | 561 | />
|
557 | 562 | {/snippet}
|
558 |
| - {@render otherChangePreview(selectedKey)} |
| 563 | + {@render otherChangePreview(selectedFile)} |
559 | 564 | </Drawer>
|
560 | 565 | {/if}
|
561 | 566 | {/snippet}
|
|
0 commit comments