Skip to content

Commit

Permalink
Merge pull request #20 from davidchalifoux/main
Browse files Browse the repository at this point in the history
v0.0.10
  • Loading branch information
davidchalifoux authored Apr 17, 2024
2 parents 9196cb5 + 1a44d14 commit 70fb6fc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct ElgatoService {
}

#[tauri::command]
fn scan() -> Vec<ElgatoService> {
async fn scan() -> Vec<ElgatoService> {
let (service_sender, service_receiver) = flume::unbounded::<ElgatoService>();

// Create a daemon
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Keylight Commander",
"version": "0.0.9"
"version": "0.0.10"
},
"tauri": {
"macOSPrivateApi": true,
Expand Down
21 changes: 18 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const App: React.FC = () => {
const [isManualAddOpen, { open: openManualAdd, close: closeManualAdd }] =
useDisclosure(false);

/** True if the Rust backend is scanning for new services */
const [isScanning, setIsScanning] = useState(false);

const [globalBrightness, setGlobalBrightness] = useState<number | null>(null);
const [globalTemperature, setGlobalTemperature] = useState<number | null>(
null
Expand All @@ -56,16 +59,27 @@ export const App: React.FC = () => {
count: 0,
});

function scanServices() {
invoke<ElgatoServiceResponse[]>("scan").then((res): void => {
/**
* Scans for services and adds them to the service store.
*/
async function scanServices(): Promise<void> {
setIsScanning(true);

try {
const res = await invoke<ElgatoServiceResponse[]>("scan");

res.forEach((service) => {
serviceStore.addService({
...service,
id: nanoid(),
name: service.full_name.split(".")[0],
});
});
});
} catch (error) {
console.error(error);
} finally {
setIsScanning(false);
}
}

const isEveryLightOn = useMemo(() => {
Expand Down Expand Up @@ -136,6 +150,7 @@ export const App: React.FC = () => {
variant="subtle"
color="gray"
onClick={() => scanServices()}
loading={isScanning}
>
<IconScanEye
style={{ width: "70%", height: "70%" }}
Expand Down

0 comments on commit 70fb6fc

Please sign in to comment.