forked from Blendman974/faceclaw
Autoconnect on reaching main screen; play sound effect on first launch
This commit is contained in:
1 parent
ea80d05607
commit
d97429a21a
5 files changed
+91
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { Application, Frame, ImageSource, Observable, Screen } from "@nativescript/core";
|
||||
import { dashboardController } from "../g2/dashboard-controller";
|
||||
import { isValidMacAddress, loadDeviceAddresses } from "../g2/device-addresses";
|
||||
|
||||
type LayoutOrientation = "portrait" | "landscape";
|
||||
|
||||
@@ -327,6 +328,22 @@ export class MainViewModel extends Observable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to connect automatically on reaching the main page. No-op if already
|
||||
* connecting/connected, or if no glasses are configured (e.g. preview-only
|
||||
* users, who have nothing to connect to).
|
||||
*/
|
||||
async autoConnect(): Promise<void> {
|
||||
if (this.phase !== "disconnected") return;
|
||||
const addresses = loadDeviceAddresses();
|
||||
if (!isValidMacAddress(addresses.right) || !isValidMacAddress(addresses.left)) return;
|
||||
try {
|
||||
await dashboardController.connect();
|
||||
} catch {
|
||||
// The controller surfaces failures via status/log; nothing to add here.
|
||||
}
|
||||
}
|
||||
|
||||
onConfigureTap(): void {
|
||||
if (!this.canRun) return;
|
||||
Frame.topmost()?.navigate("phone-ui/config-page");
|
||||
|
||||
Reference in new issue
Block a user