Explorar o código

fix(app): changes view

Adam hai 5 meses
pai
achega
3b20bf6d4f
Modificáronse 2 ficheiros con 9 adicións e 5 borrados
  1. 3 2
      packages/app/src/context/local.tsx
  2. 6 3
      packages/app/src/pages/index.tsx

+ 3 - 2
packages/app/src/context/local.tsx

@@ -124,11 +124,12 @@ function init() {
       return store.node[store.active]
     })
     const opened = createMemo(() => store.opened.map((x) => store.node[x]))
-    const changes = createMemo(() => new Set(sync.data.changes.map((f) => f.path)))
+    const changeset = createMemo(() => new Set(sync.data.changes.map((f) => f.path)))
+    const changes = createMemo(() => Array.from(changeset()).sort((a, b) => a.localeCompare(b)))
     const status = (path: string) => sync.data.changes.find((f) => f.path === path)
 
     const changed = (path: string) => {
-      const set = changes()
+      const set = changeset()
       if (set.has(path)) return true
       for (const p of set) {
         if (p.startsWith(path ? path + "/" : "")) return true

+ 6 - 3
packages/app/src/pages/index.tsx

@@ -259,9 +259,12 @@ export default function Page() {
             <FileTree path="" onFileClick={handleFileClick} />
           </Tabs.Content>
           <Tabs.Content value="changes" class="grow min-h-0 py-2 bg-background">
-            <div class="text-xs text-text-muted">
+            <Show
+              when={local.file.changes().length}
+              fallback={<div class="px-2 text-xs text-text-muted">No changes yet</div>}
+            >
               <ul class="">
-                <For each={[...local.file.changes()]}>
+                <For each={local.file.changes()}>
                   {(path) => (
                     <li>
                       <button
@@ -278,7 +281,7 @@ export default function Page() {
                   )}
                 </For>
               </ul>
-            </div>
+            </Show>
           </Tabs.Content>
         </Tabs>
       </div>