-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module level cleanup, modified thread communication
- Loading branch information
1 parent
97b33f0
commit 1c95b18
Showing
22 changed files
with
372 additions
and
200 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use self::request::handle_frontend_request; | ||
|
||
use super::AppData; | ||
use crate::{common, ThreadMsg}; | ||
use common::app::msg::FrontendMsg; | ||
mod request; | ||
|
||
/// Handles a message from the parent thread. | ||
/// Returns `true` if the app should quit. | ||
pub fn handle_thread_msg(app_data: &mut AppData, msg: ThreadMsg) -> bool { | ||
match msg { | ||
// Handle frontend message. | ||
ThreadMsg::Frontend(msg) => handle_frontend_msg(app_data, msg), | ||
// Quit. | ||
ThreadMsg::Exit => return true, | ||
}; | ||
false | ||
} | ||
|
||
/// Handles messages from the frontend. | ||
fn handle_frontend_msg(app_data: &mut AppData, msg: FrontendMsg) { | ||
match msg { | ||
FrontendMsg::Request(request) => { | ||
handle_frontend_request(app_data, request) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::app_data::AppData; | ||
use crate::{common, AppThread}; | ||
use common::app::msg::request::FrontendRequest; | ||
use common::app::msg::BackendMsg; | ||
|
||
mod backend_response; | ||
|
||
/// Handles the request and sends a response to the frontend. | ||
pub(super) fn handle_frontend_request( | ||
app_data: &mut AppData, | ||
request: FrontendRequest, | ||
) { | ||
// Handle request and prepare response. | ||
let response = match request { | ||
FrontendRequest::AppState => backend_response::app_state(app_data), | ||
FrontendRequest::Settings => backend_response::settings(app_data), | ||
FrontendRequest::UseDefaultSettings => { | ||
backend_response::use_default_settings(app_data) | ||
} | ||
}; | ||
|
||
// Send response. | ||
AppThread::send_message( | ||
&app_data.tauri_app, | ||
BackendMsg::Response(response), | ||
); | ||
} |
Oops, something went wrong.