Skip to content

Commit

Permalink
FIxed directory toggling
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Mar 10, 2025
1 parent 10def35 commit 860555f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions web/src/client/config/directories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,26 @@ function updateUrl(url: string, text: string) {
}

function toggleDirectory(d: Directory) {
d.active = !d.active
getClientState().updateDirectory(d)
const directories = getClientState().getDirectories()
const i = directories.findIndex((x) => x.url == d.url)
directories[i].active = !directories[i].active
updateDirectories(directories)
}

function updateDirectories(directories: Directory[]) {
getClientState()
.setDirectories(directories)
.then(async () => {
getClientState().setKnownApps(await getServerState().getApplications())
})
}

function removeDirectory(d: Directory) {
if (confirm("Remove this directory - are you sure?") == true) {
const directories = getClientState().getDirectories()
const i = directories.findIndex((x) => x.url == d.url)
directories.splice(i, 1)
getClientState().setDirectories(directories)
updateDirectories(directories)
}
}

Expand Down Expand Up @@ -97,13 +107,7 @@ export const DirectoryList = () => {
url: "",
active: false,
})
getClientState()
.setDirectories(directories)
.then(async () => {
getClientState().setKnownApps(
await getServerState().getApplications(),
)
})
updateDirectories(directories)
}}
/>{" "}
</div>
Expand Down

0 comments on commit 860555f

Please sign in to comment.