Refactor invokeEntry into an ArchiveController command. See #2

This commit is contained in:
2023-12-25 12:43:02 -07:00
parent 971ad0a0c5
commit 3da0a10948
2 changed files with 12 additions and 11 deletions

View File

@@ -539,4 +539,14 @@
(addComponent archive e Dates [=>"Created" (Date.now)])
})])
)
(defCommand InvokeEntry [e SelectedEntry]
(cond
((hasComponent e NATCommand)
(tryRunCommand (readComponent e NATCommand)) 0)
((hasComponent e NATCommands)
(tryRunCommands (readComponent e NATCommands)) 0)
(true
(ui.displayMessage "tried to invoke ${e.id} but it has no available actions") 0))
[e])
)

View File

@@ -16,7 +16,7 @@
(set ui.shortcutHandler.onSelectItem
->e {
(ui.hidePrefixMap)
(invokeEntry archive ui e)
(controller.InvokeEntry e)
})
(set ui.shortcutHandler.onBadKey ->[key map] (ui.displayMessage "$key is not mapped to a shortcut in this context: $map"))
(set setup true))
@@ -26,12 +26,3 @@
(dictSet descriptions (readComponent e KeyShortcut) true)))
0
}))
(method invokeEntry [archive ui :Entry e]
// TODO make this doCond
(cond
((hasComponent e NATCommand)
(controller.tryRunCommand (readComponent e NATCommand)) 0)
((hasComponent e NATCommands)
(controller.tryRunCommands (readComponent e NATCommands)) 0)
(true (ui.displayMessage "tried to invoke ${e.id} but it has no available actions"))) 0)