Skip to content

Commit

Permalink
Automatically open bloop app after authentication with GitHub (#1146)
Browse files Browse the repository at this point in the history
* create tauri command to automatically open and focus bloop app after authentication with GitHub

* fix rustfmt
  • Loading branch information
anastasiya1155 authored Nov 22, 2023
1 parent 69ab6e7 commit 295cb8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions apps/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,28 @@ fn main() {
.setup(backend::initialize)
.invoke_handler(tauri::generate_handler![
show_folder_in_finder,
show_main_window,
backend::get_last_log_file,
])
.run(tauri::generate_context!())
.expect("error running tauri application");
}

#[tauri::command]
fn show_main_window(app_handle: tauri::AppHandle) {
match app_handle.get_window("main") {
Some(window) => {
if !cfg!(target_os = "macos") {
window.unminimize().unwrap();
}
window.unminimize().unwrap();
window.set_focus().unwrap();
window.show().unwrap();
}
None => {}
}
}

#[tauri::command]
fn show_folder_in_finder(path: String) {
let path = PathBuf::from(path).canonicalize().unwrap();
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/Onboarding/Desktop/UserForm/Step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const UserFormStep2 = ({ onContinue }: Props) => {
const { isGithubConnected, setGithubConnected } = useContext(
UIContext.GitHubConnected,
);
const { envConfig, openLink, setEnvConfig } = useContext(DeviceContext);
const { envConfig, openLink, setEnvConfig, invokeTauriCommand } =
useContext(DeviceContext);
const [isTimedOut, setIsTimedOut] = useState(false);
const [isBtnClicked, setBtnClicked] = useState(false);
const [loginUrl, setLoginUrl] = useState('');
Expand Down Expand Up @@ -84,6 +85,7 @@ const UserFormStep2 = ({ onContinue }: Props) => {
() =>
checkGHAuth().then((d) => {
if (!!d.user_login) {
invokeTauriCommand('show_main_window');
onContinue();
}
}),
Expand Down

0 comments on commit 295cb8f

Please sign in to comment.