Squashed commit message
Some checks failed
Telegram Mini App Shop Builder / Compute version metadata (push) Has been cancelled
Telegram Mini App Shop Builder / Run Frontend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run Backend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run PHP_CodeSniffer (push) Has been cancelled
Telegram Mini App Shop Builder / Build module. (push) Has been cancelled
Telegram Mini App Shop Builder / release (push) Has been cancelled
Some checks failed
Telegram Mini App Shop Builder / Compute version metadata (push) Has been cancelled
Telegram Mini App Shop Builder / Run Frontend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run Backend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run PHP_CodeSniffer (push) Has been cancelled
Telegram Mini App Shop Builder / Build module. (push) Has been cancelled
Telegram Mini App Shop Builder / release (push) Has been cancelled
This commit is contained in:
39
frontend/spa/src/composables/useHapticFeedback.js
Normal file
39
frontend/spa/src/composables/useHapticFeedback.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import {useSettingsStore} from "@/stores/SettingsStore.js";
|
||||
|
||||
/**
|
||||
* Composable для безопасной работы с HapticFeedback
|
||||
* Проверяет настройку haptic_enabled перед использованием
|
||||
* @returns {object} Объект с методами haptic feedback, которые безопасно вызываются
|
||||
*/
|
||||
export function useHapticFeedback() {
|
||||
const settings = useSettingsStore();
|
||||
const haptic = window.Telegram?.WebApp?.HapticFeedback;
|
||||
|
||||
// Возвращаем обёртку с методами, которые проверяют настройку при каждом вызове
|
||||
return {
|
||||
impactOccurred: (style) => {
|
||||
// Проверяем настройку при каждом вызове (реактивно)
|
||||
const isHapticEnabled = settings.haptic_enabled !== false;
|
||||
if (!haptic || !isHapticEnabled || !haptic.impactOccurred) {
|
||||
return;
|
||||
}
|
||||
haptic.impactOccurred(style);
|
||||
},
|
||||
selectionChanged: () => {
|
||||
// Проверяем настройку при каждом вызове (реактивно)
|
||||
const isHapticEnabled = settings.haptic_enabled !== false;
|
||||
if (!haptic || !isHapticEnabled || !haptic.selectionChanged) {
|
||||
return;
|
||||
}
|
||||
haptic.selectionChanged();
|
||||
},
|
||||
notificationOccurred: (type) => {
|
||||
// Проверяем настройку при каждом вызове (реактивно)
|
||||
const isHapticEnabled = settings.haptic_enabled !== false;
|
||||
if (!haptic || !isHapticEnabled || !haptic.notificationOccurred) {
|
||||
return;
|
||||
}
|
||||
haptic.notificationOccurred(type);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user