Final touches

This commit is contained in:
lights0123 2020-09-27 15:54:28 -04:00
parent 84d5e82d1a
commit 944e3a39c5
No known key found for this signature in database
GPG key ID: 28F315322E37972F
5 changed files with 41 additions and 28 deletions

View file

@ -3,7 +3,7 @@ on:
push:
branches-ignore:
- 'dependabot/**'
- publish
- release
pull_request:
jobs:
@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-18.04, windows-latest]
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:

View file

@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-18.04, windows-latest]
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:

View file

@ -1,7 +1,7 @@
// #![cfg_attr(
// all(not(debug_assertions), target_os = "windows"),
// windows_subsystem = "windows"
// )]
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use hashbrown::HashMap;
use std::fs::File;
@ -88,22 +88,22 @@ impl Hotplug<GlobalContext> for DeviceMon {
}
fn device_left(&mut self, device: rusb::Device<GlobalContext>) {
// if let Some((dev, _)) = DEVICES
// .write()
// .unwrap()
// .remove_entry(&(device.bus_number(), device.address()))
// {
// if let Err(msg) = tauri::event::emit(
// &mut self.handle,
// "removeDevice",
// Some(DevId {
// bus_number: dev.0,
// address: dev.1,
// }),
// ) {
// eprintln!("{}", msg);
// };
// }
if let Some((dev, _)) = DEVICES
.write()
.unwrap()
.remove_entry(&(device.bus_number(), device.address()))
{
if let Err(msg) = tauri::event::emit(
&mut self.handle,
"removeDevice",
Some(DevId {
bus_number: dev.0,
address: dev.1,
}),
) {
eprintln!("{}", msg);
};
}
}
}

View file

@ -119,9 +119,10 @@ let queueId = 0;
class Devices extends Vue {
devices: Record<string, Device> = {};
enumerating = false;
hasEnumerated = false;
created() {
this.enumerate().catch(console.error);
this.enumerate().then(() => this.hasEnumerated = true, console.error);
listen('addDevice', dev => {
const payload = dev.payload as Device & DevId;
const str = devToString(payload);

View file

@ -12,7 +12,7 @@
</p>
</div>
<div v-else-if="calculator && !calculator.info" class="flex items-center justify-center h-full">
<div class="lds-dual-ring" />
<div class="lds-dual-ring"/>
</div>
<div v-else-if="calculator && calculator.info">
<calc-info :info="calculator.info" :dev="selectedCalculator"/>
@ -39,6 +39,10 @@ import CalcInfo from '@/components/CalcInfo.vue';
import FileBrowser from '@/components/FileBrowser.vue';
import DeviceSelect from "@/components/DeviceSelect.vue";
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@Component({
components: {
DeviceSelect,
@ -50,9 +54,17 @@ export default class Home extends Vue {
selectedCalculator: string | null = null;
showHidden = false;
@Watch('$devices.hasEnumerated')
onEnumerated() {
const first = Object.keys(this.$devices.devices)[0];
if (first) this.selectedCalculator = first;
}
@Watch('$devices.devices')
onDeviceChange() {
async onDeviceChange() {
if (!this.selectedCalculator) {
await sleep(1000);
if (this.selectedCalculator) return;
const first = Object.keys(this.$devices.devices)[0];
if (first) this.selectedCalculator = first;
} else if (!Object.keys(this.$devices.devices).includes(this.selectedCalculator)) {
@ -67,7 +79,7 @@ export default class Home extends Vue {
if (dev && !this.$devices.devices[dev].info && !this.$devices.devices[dev].needsDrivers) {
try {
await this.$devices.open(dev);
}catch(e) {
} catch (e) {
console.error(e);
this.selectedCalculator = null;
}
@ -83,7 +95,7 @@ export default class Home extends Vue {
}
installDrivers() {
open('https://zadig.akeo.ie/');
open('https://lights0123.com/n-link/#windows');
}
}
</script>