|
19 | 19 | ) |
20 | 20 | ) |
21 | 21 |
|
22 | | - let selected = $state(0) |
23 | | - const runningIdx = $derived(running.indexOf(process)) |
24 | | - $effect(() => { |
25 | | - if (runningIdx == -1) { |
26 | | - const stoppedIdx = stopped.indexOf(process) |
27 | | - if (stoppedIdx != -1) { |
28 | | - selected = stoppedIdx + running.length |
29 | | - } else { |
30 | | - selected = 0 |
31 | | - } |
32 | | - } |
| 22 | + const selected = $derived.by(() => { |
| 23 | + const i = running.indexOf(process) |
| 24 | + if (i > -1) return i |
| 25 | + const idx = stopped.indexOf(process) |
| 26 | + if (idx == -1) return 0 |
| 27 | + return idx + running.length |
33 | 28 | }) |
34 | 29 |
|
35 | 30 | const hasProcesses = $derived(running.length > 0 || stopped.length > 0) |
|
53 | 48 | <ul class="h-full w-full overflow-y-scroll"> |
54 | 49 | {#each running as entry, idx} |
55 | 50 | <li |
56 | | - class="flex preset-outlined-success-200-800 hover:preset-tonal focus:preset-tonal" |
| 51 | + class="flex preset-outlined-success-200-800 text-sm hover:preset-tonal focus:preset-tonal" |
57 | 52 | class:bg-surface-300-700={selected === idx} |
58 | 53 | class:border-primary-300-700={selected === idx} |
59 | 54 | > |
60 | | - <a |
61 | | - href={"/running/" + entry} |
62 | | - class="my-2 flex h-full w-full justify-between px-2" |
63 | | - onclick={() => (selected = idx)} |
64 | | - > |
| 55 | + <a href={"/running/" + entry} class="my-2 flex h-full w-full justify-between px-2"> |
65 | 56 | {channelManager.channels[entry].name} |
66 | 57 | </a> |
67 | 58 | </li> |
|
73 | 64 | class:bg-surface-300-700={selected === idx + running.length} |
74 | 65 | class:border-primary-300-700={selected === idx + running.length} |
75 | 66 | > |
76 | | - <a |
77 | | - href={"/running/" + entry} |
78 | | - class="my-2 flex h-full w-full justify-between px-2" |
79 | | - onclick={() => (selected = idx + running.length)} |
80 | | - > |
| 67 | + <a href={"/running/" + entry} class="my-2 flex h-full w-full justify-between px-2"> |
81 | 68 | {channelManager.channels[entry].name} |
82 | 69 | </a> |
83 | 70 | </li> |
|
107 | 94 | class="btn rounded-lg border border-surface-500 bg-surface-500/70 p-2" |
108 | 95 | onclick={async () => { |
109 | 96 | channelManager.removeChannel(stopped[selected - running.length]) |
110 | | - selected = -1 |
111 | 97 | await Promise.all([invalidate("layout:channel"), invalidate("layout:running")]) |
112 | 98 | await goto("/running") |
113 | 99 | }} |
|
119 | 105 | {/if} |
120 | 106 |
|
121 | 107 | <div |
122 | | - class="block min-h-full w-full min-w-fit gap-2 px-4 text-left font-mono text-sm wrap-break-word whitespace-break-spaces" |
| 108 | + class="block min-h-full w-full min-w-fit gap-2 px-4 text-left wrap-break-word whitespace-break-spaces" |
123 | 109 | class:bg-stone-950={hasProcesses} |
124 | 110 | class:overflow-y-scroll={hasProcesses} |
125 | 111 | > |
|
0 commit comments