Sort constraint buttons (#1161)

add sorting to constraintns
This commit is contained in:
Kurt Hutten
2023-12-01 20:49:26 +11:00
committed by GitHub
parent 9c58cde35f
commit 2bd3b06178

View File

@ -109,6 +109,21 @@ export const Toolbar = () => {
eventName.includes('Make segment') ||
eventName.includes('Constrain')
)
.sort((a, b) => {
const aisEnabled = state.nextEvents
.filter((event) => state.can(event as any))
.includes(a)
const bIsEnabled = state.nextEvents
.filter((event) => state.can(event as any))
.includes(b)
if (aisEnabled && !bIsEnabled) {
return -1
}
if (!aisEnabled && bIsEnabled) {
return 1
}
return 0
})
.map((eventName) => (
<button
key={eventName}