diff --git a/packages/app/src/cores/haptics/haptics.core.js b/packages/app/src/cores/haptics/haptics.core.js new file mode 100644 index 00000000..dfb34ec4 --- /dev/null +++ b/packages/app/src/cores/haptics/haptics.core.js @@ -0,0 +1,28 @@ +import Core from "evite/src/core" + +export default class HapticsCore extends Core { + static refName = "haptics" + static namespace = "haptics" + static dependencies = [ + "settings" + ] + + static get isGlobalDisabled() { + return app.cores.settings.get("haptic_feedback") + } + + public = { + isGlobalDisabled: HapticsCore.isGlobalDisabled, + vibration: this.vibration.bind(this), + } + + vibration(...args) { + const disabled = this.isGlobalDisabled + + if (disabled) { + return false + } + + return navigator.vibrate(...args) + } +} \ No newline at end of file