Skip to content

Commit 1f6c201

Browse files
committed
Make EnableFingerprint store
1 parent d3bf3cb commit 1f6c201

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed

src/StaticConfiguration.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,10 @@ class StaticConfiguration {
148148
* Whether the knn model should be normalized by default
149149
*/
150150
public static readonly knnNormalizedDefault = false;
151+
152+
/**
153+
* Whether fingerprinting should be enabled by default
154+
*/
155+
public static readonly enableFingerprintByDefault: boolean = false;
151156
}
152157
export default StaticConfiguration;

src/components/features/datacollection/Gesture.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
3434
const defaultNewName = $t('content.data.classPlaceholderNewClass');
3535
const recordingDuration = StaticConfiguration.recordingDuration;
36+
const enableFingerprint = stores.getEnableFingerprint();
3637
3738
let isThisRecording = false;
3839
@@ -219,7 +220,7 @@
219220
<div class="flex p-2 h-30">
220221
{#each $gesture.recordings as recording (String($gesture.ID) + String(recording.ID))}
221222
<Recording
222-
enableFingerprint={true}
223+
enableFingerprint={$enableFingerprint}
223224
downloadable
224225
{recording}
225226
gestureId={$gesture.ID}

src/components/ui/recording/Recording.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
export let onDelete: (recording: RecordingData) => void;
2424
export let dot: { gesture: GestureID; color: string } | undefined = undefined;
2525
export let downloadable: boolean = false;
26-
export let enableFingerprint: boolean = false;
26+
export let enableFingerprint: boolean;
2727
2828
$: dotGesture = dot?.gesture
2929
? stores.getGestures().getGesture(dot?.gesture)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* (c) 2023-2025, Center for Computational Thinking and Design at Aarhus University and contributors
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
import { derived, get, writable, type Subscriber, type Unsubscriber, type Writable } from 'svelte/store';
7+
8+
class EnableFingerprint implements Writable<boolean> {
9+
private value: Writable<boolean>;
10+
11+
public constructor(defaultValue: boolean) {
12+
this.value = writable(defaultValue);
13+
}
14+
15+
public set(newValue: boolean): void {
16+
this.value.set(newValue);
17+
}
18+
19+
public update(updater: (state: boolean) => boolean): void {
20+
const beforeValue = get(this.value);
21+
const updatedValue = updater(beforeValue);
22+
this.set(updatedValue);
23+
}
24+
25+
public subscribe(run: Subscriber<boolean>, invalidate?: (value?: boolean) => void): Unsubscriber {
26+
return derived([this.value], ([store]) => store).subscribe(run, invalidate);
27+
}
28+
}
29+
30+
export default EnableFingerprint;

src/lib/stores/Stores.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import ValidationResults from '../domain/stores/ValidationResults';
3535
import Snackbar from './Snackbar';
3636
import { knnHasTrained } from './KNNStores';
3737
import Devices from '../domain/Devices';
38+
import EnableFingerprint from '../domain/stores/EnableFingerprint';
39+
import StaticConfiguration from '../../StaticConfiguration';
3840

3941
type StoresType = {
4042
liveData: LiveData<LiveDataVector> | undefined;
@@ -59,6 +61,7 @@ class Stores implements Readable<StoresType> {
5961
private validationResults: ValidationResults;
6062
private recorder: Recorder;
6163
private devices: Devices;
64+
private enableFingerprint: EnableFingerprint;
6265

6366
public constructor() {
6467
this.devices = new Devices();
@@ -90,6 +93,7 @@ class Stores implements Readable<StoresType> {
9093
this.gestures,
9194
this.highlightedAxis,
9295
);
96+
this.enableFingerprint = new EnableFingerprint(StaticConfiguration.enableFingerprintByDefault);
9397
}
9498

9599
public subscribe(
@@ -182,6 +186,10 @@ class Stores implements Readable<StoresType> {
182186
public getDevices(): Devices {
183187
return this.devices;
184188
}
189+
190+
public getEnableFingerprint() {
191+
return this.enableFingerprint;
192+
}
185193
}
186194

187195
export const stores = new Stores();

0 commit comments

Comments
 (0)