From 9a91a2ac41a5b2fbc2811922750a782b45115219 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 30 Jun 2026 19:55:11 +0300 Subject: refactor: route tui mutations through runtime dispatch --- src/app/runtime_mutations.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/app/runtime_mutations.rs (limited to 'src/app/runtime_mutations.rs') diff --git a/src/app/runtime_mutations.rs b/src/app/runtime_mutations.rs new file mode 100644 index 00000000..fae52d60 --- /dev/null +++ b/src/app/runtime_mutations.rs @@ -0,0 +1,59 @@ +use crate::api::schema::{Method, PaneTarget, TabTarget, WorkspaceTarget}; + +use super::App; + +impl App { + pub(crate) fn dispatch_tui_runtime_mutation( + &mut self, + id: &'static str, + method: Method, + ) -> String { + self.dispatch_tui_api_request(id, method) + } + + pub(crate) fn dispatch_tui_deferred_runtime_mutation( + &mut self, + id: &'static str, + method: Method, + ) -> Option { + self.dispatch_tui_deferred_api_request(id, method) + } + + pub(crate) fn runtime_workspace_focus( + &mut self, + id: &'static str, + workspace_id: String, + ) -> String { + self.dispatch_tui_runtime_mutation( + id, + Method::WorkspaceFocus(WorkspaceTarget { workspace_id }), + ) + } + + pub(crate) fn runtime_workspace_close( + &mut self, + id: &'static str, + workspace_id: String, + ) -> String { + self.dispatch_tui_runtime_mutation( + id, + Method::WorkspaceClose(WorkspaceTarget { workspace_id }), + ) + } + + pub(crate) fn runtime_tab_focus(&mut self, id: &'static str, tab_id: String) -> String { + self.dispatch_tui_runtime_mutation(id, Method::TabFocus(TabTarget { tab_id })) + } + + pub(crate) fn runtime_tab_close(&mut self, id: &'static str, tab_id: String) -> String { + self.dispatch_tui_runtime_mutation(id, Method::TabClose(TabTarget { tab_id })) + } + + pub(crate) fn runtime_pane_focus(&mut self, id: &'static str, pane_id: String) -> String { + self.dispatch_tui_runtime_mutation(id, Method::PaneFocus(PaneTarget { pane_id })) + } + + pub(crate) fn runtime_pane_close(&mut self, id: &'static str, pane_id: String) -> String { + self.dispatch_tui_runtime_mutation(id, Method::PaneClose(PaneTarget { pane_id })) + } +} -- cgit v1.2.3