drafts: Refactor keyboard functions for reusability.

This is a preparatory commit to implement keyboard navigation in the
 message scheduling modal. The main goal is to make the
 `modals_handle_events` function reusable. To achieve this, we have
 extracted all the context-related variables and replaced all
 mentions of "draft" with the more neutral term "item". The
 `modals_handle_events` function now also has a context parameter,
 which contains all the necessary methods and properties to work in
 different modal contexts.
This commit is contained in:
Daniil Fadeev
2023-05-12 13:02:42 +04:00
committed by Tim Abbott
parent 0117d751c2
commit 35c23d0269
3 changed files with 148 additions and 105 deletions

View File

@@ -524,8 +524,8 @@ run_test("motion_keys", () => {
delete overlays.is_active;
overlays.drafts_open = () => true;
assert_mapping("up_arrow", drafts, "drafts_handle_events");
assert_mapping("down_arrow", drafts, "drafts_handle_events");
assert_mapping("up_arrow", drafts, "handle_keyboard_events");
assert_mapping("down_arrow", drafts, "handle_keyboard_events");
delete overlays.is_active;
delete overlays.drafts_open;
});