mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Clean up redundant messages on the Pair Glasses page
This commit is contained in:
1 parent
fa663804de
commit
bf66c5a53c
5 files changed
+5
-33
No files matched your search
+1
-14
@@ -27,7 +27,7 @@
|
|||||||
*
|
*
|
||||||
* It is **not** a measurement. A hand over the temple, a pocket, or a body
|
* It is **not** a measurement. A hand over the temple, a pocket, or a body
|
||||||
* between phone and glasses moves the estimate by metres. The wearer therefore
|
* between phone and glasses moves the estimate by metres. The wearer therefore
|
||||||
* only ever sees a coarse zone (glyph + label), never a number in metres they
|
* only ever sees a coarse zone (a signal-strength glyph), never a number in metres they
|
||||||
* might over-trust; the metres value exists purely to rank and bucket.
|
* might over-trust; the metres value exists purely to rank and bucket.
|
||||||
*
|
*
|
||||||
* This module is pure (no NativeScript imports) so it can run under node tests.
|
* This module is pure (no NativeScript imports) so it can run under node tests.
|
||||||
@@ -75,19 +75,6 @@ export function zoneFromMeters(meters: number): ProximityZone {
|
|||||||
return "distant";
|
return "distant";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function zoneLabel(zone: ProximityZone): string {
|
|
||||||
switch (zone) {
|
|
||||||
case "immediate":
|
|
||||||
return "In your hand";
|
|
||||||
case "near":
|
|
||||||
return "Nearby";
|
|
||||||
case "far":
|
|
||||||
return "Across the room";
|
|
||||||
case "distant":
|
|
||||||
return "Far away";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A glyph for the zone; SF Symbols have no Android equivalent, so plain text. */
|
/** A glyph for the zone; SF Symbols have no Android equivalent, so plain text. */
|
||||||
export function zoneGlyph(zone: ProximityZone): string {
|
export function zoneGlyph(zone: ProximityZone): string {
|
||||||
switch (zone) {
|
switch (zone) {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
RING_CALIBRATION,
|
RING_CALIBRATION,
|
||||||
sortedByProximity,
|
sortedByProximity,
|
||||||
zoneGlyph,
|
zoneGlyph,
|
||||||
zoneLabel,
|
|
||||||
type ProximityEstimate,
|
type ProximityEstimate,
|
||||||
type ProximityZone,
|
type ProximityZone,
|
||||||
} from "./ble-proximity";
|
} from "./ble-proximity";
|
||||||
@@ -329,7 +328,6 @@ export type PairingRowPresentation = {
|
|||||||
isPreviouslyPaired: boolean;
|
isPreviouslyPaired: boolean;
|
||||||
/** "Yours" / "Closest" / "". */
|
/** "Yours" / "Closest" / "". */
|
||||||
badge: string;
|
badge: string;
|
||||||
proximitySummary: string;
|
|
||||||
proximityGlyph: string;
|
proximityGlyph: string;
|
||||||
zone: ProximityZone | null;
|
zone: ProximityZone | null;
|
||||||
/** "Left + right arms found", "Only the left arm has been seen", …; "" when there is nothing worth a line (an unbonded ring). */
|
/** "Left + right arms found", "Only the left arm has been seen", …; "" when there is nothing worth a line (an unbonded ring). */
|
||||||
@@ -355,12 +353,11 @@ function presentationBase(
|
|||||||
isNearest: boolean,
|
isNearest: boolean,
|
||||||
isPaired: boolean,
|
isPaired: boolean,
|
||||||
warnings: readonly string[],
|
warnings: readonly string[],
|
||||||
): Pick<PairingRowPresentation, "isNearest" | "isPreviouslyPaired" | "badge" | "proximitySummary" | "proximityGlyph" | "zone" | "warning"> {
|
): Pick<PairingRowPresentation, "isNearest" | "isPreviouslyPaired" | "badge" | "proximityGlyph" | "zone" | "warning"> {
|
||||||
return {
|
return {
|
||||||
isNearest,
|
isNearest,
|
||||||
isPreviouslyPaired: isPaired,
|
isPreviouslyPaired: isPaired,
|
||||||
badge: isPaired ? "Yours" : isNearest ? "Closest" : "",
|
badge: isPaired ? "Yours" : isNearest ? "Closest" : "",
|
||||||
proximitySummary: proximity ? zoneLabel(proximity.zone) : "Signal unknown",
|
|
||||||
proximityGlyph: proximity ? zoneGlyph(proximity.zone) : "○○○○",
|
proximityGlyph: proximity ? zoneGlyph(proximity.zone) : "○○○○",
|
||||||
zone: proximity?.zone ?? null,
|
zone: proximity?.zone ?? null,
|
||||||
warning: warnings.join(" "),
|
warning: warnings.join(" "),
|
||||||
|
|||||||
@@ -504,22 +504,12 @@ export class PairingViewModel extends Observable {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const complete = pairs.filter((pair) => pair.completeness === "complete").length;
|
|
||||||
const partial = pairs.length - complete;
|
|
||||||
if (this.scanFailure) {
|
if (this.scanFailure) {
|
||||||
this.status = `Scan failed: ${this.scanFailure}`;
|
this.status = `Scan failed: ${this.scanFailure}`;
|
||||||
} else if (!this._scanning) {
|
} else if (!this._scanning) {
|
||||||
this.status = "Scan paused.";
|
this.status = "Scan paused.";
|
||||||
} else if (!pairs.length && !rings.length && !rayneos.length) {
|
|
||||||
this.status = "Scanning…";
|
|
||||||
} else {
|
} else {
|
||||||
const bits = [
|
this.status = "Scanning…";
|
||||||
complete ? `${complete} ${complete === 1 ? "pair" : "pairs"} ready` : null,
|
|
||||||
partial ? `${partial} with one arm heard` : null,
|
|
||||||
rings.length ? `${rings.length} ${rings.length === 1 ? "ring" : "rings"}` : null,
|
|
||||||
rayneos.length ? `${rayneos.length} RayNeo iO` : null,
|
|
||||||
].filter(Boolean);
|
|
||||||
this.status = `Scanning… ${bits.join(" · ")}. Tap a pair to select it.`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const property of [
|
for (const property of [
|
||||||
@@ -554,7 +544,7 @@ function toRowItem(row: PairingRowPresentation, selected: boolean, onRowTap: (ar
|
|||||||
colorwayLabel: colorwayLabel(row.colorway),
|
colorwayLabel: colorwayLabel(row.colorway),
|
||||||
badgeVisibility: row.badge ? "visible" : "collapse",
|
badgeVisibility: row.badge ? "visible" : "collapse",
|
||||||
variantVisibility: row.variantSummary ? "visible" : "collapse",
|
variantVisibility: row.variantSummary ? "visible" : "collapse",
|
||||||
proximityLine: `${row.proximityGlyph} ${row.proximitySummary}`,
|
proximityLine: row.proximityGlyph,
|
||||||
proximityClass: row.zone === "immediate" ? "pairing-proximity pairing-proximity-immediate" : "pairing-proximity",
|
proximityClass: row.zone === "immediate" ? "pairing-proximity pairing-proximity-immediate" : "pairing-proximity",
|
||||||
armsVisibility: row.armsSummary ? "visible" : "collapse",
|
armsVisibility: row.armsSummary ? "visible" : "collapse",
|
||||||
warningVisibility: row.warning ? "visible" : "collapse",
|
warningVisibility: row.warning ? "visible" : "collapse",
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ const {
|
|||||||
MINIMUM_METERS,
|
MINIMUM_METERS,
|
||||||
MAXIMUM_METERS,
|
MAXIMUM_METERS,
|
||||||
zoneFromMeters,
|
zoneFromMeters,
|
||||||
zoneLabel,
|
|
||||||
sortedByProximity,
|
sortedByProximity,
|
||||||
} = require("../.test-build/app/g2/ble-proximity.js");
|
} = require("../.test-build/app/g2/ble-proximity.js");
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@ test("zones and their boundaries", () => {
|
|||||||
assert.equal(zoneFromMeters(3), "far");
|
assert.equal(zoneFromMeters(3), "far");
|
||||||
assert.equal(zoneFromMeters(9.9), "far");
|
assert.equal(zoneFromMeters(9.9), "far");
|
||||||
assert.equal(zoneFromMeters(10), "distant");
|
assert.equal(zoneFromMeters(10), "distant");
|
||||||
assert.equal(zoneLabel("immediate"), "In your hand");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("weak signals carry lower confidence", () => {
|
test("weak signals carry lower confidence", () => {
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ test("scan row carries the decoded variant, artwork, and proximity", () => {
|
|||||||
assert.equal(row.colorway, "brown");
|
assert.equal(row.colorway, "brown");
|
||||||
assert.equal(row.imagePath, "~/images/glasses/glasses_g2_b_brown.png");
|
assert.equal(row.imagePath, "~/images/glasses/glasses_g2_b_brown.png");
|
||||||
assert.equal(row.hasVariantImage, true);
|
assert.equal(row.hasVariantImage, true);
|
||||||
assert.match(row.proximitySummary, /In your hand|Nearby/);
|
assert.match(row.proximityGlyph, /^●●●[●○]$/);
|
||||||
assert.match(row.armsSummary, /serials match/);
|
assert.match(row.armsSummary, /serials match/);
|
||||||
assert.equal(row.canSelect, true);
|
assert.equal(row.canSelect, true);
|
||||||
assert.equal(row.isNearest, false);
|
assert.equal(row.isNearest, false);
|
||||||
|
|||||||
Reference in new issue
Block a user