Add two-way tool option messaging system between frontend/backend (#361)

* Add two-way tool option messaging system

* Rename tool option functions

* Move repeated frontend messaging code to function

* Address style comments

* Rename variable to be more descriptive

* Move tool options update to SetActiveTool message

* Refactor record of all tool options

* Only pass active tool options to bar

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Henry Sloan
2021-08-29 00:43:27 -04:00
committed by Keavon Chambers
parent 05ac4ac9b8
commit 9e73cce281
7 changed files with 59 additions and 32 deletions

View File

@@ -108,7 +108,9 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, &InputPreprocessor)>
tool_data.active_tool_type = new_tool;
// Notify the frontend about the new active tool to be displayed
responses.push_back(FrontendMessage::SetActiveTool { tool_name: new_tool.to_string() }.into());
let tool_name = new_tool.to_string();
let tool_options = self.tool_state.document_tool_data.tool_options.get(&new_tool).map(|tool_options| *tool_options);
responses.push_back(FrontendMessage::SetActiveTool { tool_name, tool_options }.into());
}
SwapColors => {
let document_data = &mut self.tool_state.document_tool_data;