✅ Fixes build warning and errors
This commit is contained in:
@@ -2,19 +2,19 @@ import { api } from '$lib/api';
|
||||
import { notifications } from '$lib/components/toasts/notifications';
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
|
||||
let featureFlagsStore: Writable<Record<string, boolean>>;
|
||||
let featureFlagsStore: Writable<Record<string, boolean | string>>;
|
||||
|
||||
export function useFeatureFlags() {
|
||||
if (!featureFlagsStore) {
|
||||
featureFlagsStore = writable<Record<string, boolean>>({});
|
||||
if (!featureFlagsStore) {
|
||||
featureFlagsStore = writable<Record<string, boolean | string>>({});
|
||||
|
||||
api.get<Record<string, boolean>>('/api/features').then((result) => {
|
||||
if (result.isOk()) featureFlagsStore.set(result.inner);
|
||||
else {
|
||||
notifications.error('Feature flag could not be fetched', 2500);
|
||||
}
|
||||
});
|
||||
}
|
||||
api.get<Record<string, boolean>>('/api/features').then(result => {
|
||||
if (result.isOk()) featureFlagsStore.set(result.inner);
|
||||
else {
|
||||
notifications.error('Feature flag could not be fetched', 2500);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return featureFlagsStore;
|
||||
}
|
||||
return featureFlagsStore;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { persistentStore } from '$lib/utilities';
|
||||
import { writable } from 'svelte/store';
|
||||
import appEnv from 'app-env';
|
||||
import { PUBLIC_VITE_USE_HOST_NAME } from '$env/static/public';
|
||||
|
||||
export const location = appEnv.VITE_USE_HOST_NAME ? writable('') : persistentStore('location', '');
|
||||
export const location = PUBLIC_VITE_USE_HOST_NAME ? writable('') : persistentStore('location', '');
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { readable } from 'svelte/store';
|
||||
|
||||
export const heading = readable(0, (set) => {
|
||||
const updateHeading = (e: any) => {
|
||||
let alpha;
|
||||
if (e.webkitCompassHeading) alpha = e.webkitCompassHeading;
|
||||
else if (e.alpha) alpha = e.alpha;
|
||||
else {
|
||||
let q = e.target.quaternion;
|
||||
alpha =
|
||||
Math.atan2(2 * q[0] * q[1] + 2 * q[2] * q[3], 1 - 2 * q[1] * q[1] - 2 * q[2] * q[2]) *
|
||||
(180 / Math.PI);
|
||||
if (alpha < 0) alpha += 360;
|
||||
}
|
||||
set(alpha);
|
||||
};
|
||||
if ('AbsoluteOrientationSensor' in window) {
|
||||
var sensor = new window.AbsoluteOrientationSensor({ frequency: 60 }) as any;
|
||||
sensor.addEventListener('reading', updateHeading);
|
||||
sensor.start();
|
||||
} else if (window.DeviceMotionEvent) window.addEventListener('deviceorientation', updateHeading);
|
||||
|
||||
return () => {
|
||||
if ('AbsoluteOrientationSensor' in window) sensor.removeEventListener('reading', updateHeading);
|
||||
window.addEventListener('deviceorientation', updateHeading);
|
||||
};
|
||||
});
|
||||
@@ -17,7 +17,7 @@ const decodeMessage = (data: string | ArrayBuffer): SocketMessage | null => {
|
||||
}
|
||||
return JSON.parse(data as string);
|
||||
} catch (error) {
|
||||
console.error(`Could not decode data: ${data} - ${error}`);
|
||||
console.error(`Could not decode data: ${new Uint8Array(data as ArrayBuffer)} - ${error}`);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user