Skip to content

Commit

Permalink
Consolidate isNearby watchers
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Nov 23, 2024
1 parent 17f7309 commit 34b5950
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/state/beacon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@ describe("beacon", () => {

myLocation.setLocation(beacon.latitude!, beacon.longitude!);
expect(isNearby.value).to.be.true;
//FIXME Beacon should be auto-disabled when we're nearME
//expect(beacon.enabled).to.be.false;
});
});
9 changes: 1 addition & 8 deletions src/state/beacon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Daniel W. Steinbrook.

import { point } from '@turf/turf';
import { computed, reactive, watch } from 'vue';
import { computed, reactive } from 'vue';
import { distanceTo, normalizedRelativePositionTo } from '../state/location';
import { MappablePoint } from '../composables/layer';

Expand Down Expand Up @@ -89,11 +89,4 @@ export const isNearby = computed(() => {
distanceMeters.value !== undefined &&
distanceMeters.value < foundProximityMeters
);
});

// Disable beacon when nearby
watch(isNearby, (newValue, oldValue) => {
if (newValue === true && oldValue === false) {
beacon.disable();
}
});
1 change: 1 addition & 0 deletions src/state/beacon_audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class BeaconAudio {
// Play "beacon found" effect when target is reached
watch(isNearby, (newValue, oldValue) => {
if (newValue === true && oldValue === false) {
beacon.disable();
new Audio(SS_beaconFound2_48k_wav).play();
}
});
Expand Down

0 comments on commit 34b5950

Please sign in to comment.