generated from marc2332/tauri-deno-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52de472
commit ded5008
Showing
21 changed files
with
381 additions
and
627 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"PCWSTR", | ||
"repr", | ||
"tauri", | ||
"Uncategorized" | ||
"Uncategorized", | ||
"unlisten" | ||
] | ||
} |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
use crate::cmd::battery_reporter::restart_interval; | ||
use tauri::{AppHandle, Manager as _}; | ||
|
||
/// # Note | ||
/// Interval callback fn cannot return Result. So relies on internal error log. | ||
pub fn start_interval(app: &tauri::AppHandle) { | ||
pub fn start_interval(app: &AppHandle) { | ||
let app = app.clone(); | ||
let window = app.get_window("main").unwrap(); | ||
tauri::async_runtime::spawn(async move { | ||
let _ = restart_interval(app).await; | ||
let _ = restart_interval(window).await; | ||
}); | ||
} |
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,31 @@ | ||
import { listen } from '@tauri-apps/api/event'; | ||
|
||
import type { BluetoothDeviceInfo } from '@/backend_api'; | ||
import { notify } from '@/components/notifications'; | ||
|
||
import type { EventCallback } from '@tauri-apps/api/event'; | ||
import type { JSX } from 'react/jsx-runtime'; | ||
|
||
type ListenerProps = { | ||
setDev: (devices: BluetoothDeviceInfo[]) => void; | ||
/** @default Error */ | ||
error?: string | JSX.Element; | ||
}; | ||
|
||
export async function deviceListener({ setDev, error }: ListenerProps) { | ||
let unlisten: (() => void) | null = null; | ||
const eventHandler: EventCallback<BluetoothDeviceInfo[]> = (event) => { | ||
setDev(event.payload); | ||
}; | ||
|
||
try { | ||
// Setup before run Promise(For event hook) | ||
unlisten = await listen<BluetoothDeviceInfo[]>('bt_monitor://restart_interval', eventHandler); | ||
return unlisten; | ||
} catch (err) { | ||
notify.error(error ?? `${err}`); | ||
if (unlisten) { | ||
unlisten(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// @index('./*', f => `export * from '${f.path}'`) | ||
export * from './backup'; | ||
export * from './backend_config'; | ||
export * from './backup'; | ||
export * from './bluetooth_finder'; | ||
export * from './default_api_wrapper'; | ||
export * from './device_listener'; | ||
export * from './lang'; | ||
export * from './log'; | ||
export * from './progress_listener'; | ||
export * from './sys_tray'; |
This file was deleted.
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
Oops, something went wrong.