Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: wrap haptics (#2348)

Peter Chinman2189c0c121a0
diff --git a/js/app/packages/app/component/mobile/EntityRow.tsx b/js/app/packages/app/component/mobile/EntityRow.tsx
index fcc9963a46..a1252fc3b6 100644
--- a/js/app/packages/app/component/mobile/EntityRow.tsx
+++ b/js/app/packages/app/component/mobile/EntityRow.tsx
@@ -1,4 +1,4 @@
-import { impactFeedback } from '@tauri-apps/plugin-haptics';
+import { hapticImpact } from '@core/mobile/haptics';
import {
type Accessor,
createContext,
@@ -332,7 +332,7 @@ export function EntityRowProvider(
if (thesholdCrossed) {
if (phase !== 'threshold') {
- impactFeedback('light');
+ hapticImpact('light');
setState(touchState.entityId, {
direction: dx > 0 ? 'right' : 'left',
phase: 'threshold',
@@ -341,7 +341,7 @@ export function EntityRowProvider(
} else {
if (phase !== 'dragging') {
if (phase === 'threshold') {
- impactFeedback('light');
+ hapticImpact('light');
}
setState(touchState.entityId, {
direction: dx > 0 ? 'right' : 'left',
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index 66b5de4012..e7057bc16d 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -6,7 +6,7 @@ import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';
import { AnimatedFileMdIcon } from '@macro-icons/wide/animating/fileMd';
import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';
import { AnimatedPlusIcon } from '@macro-icons/wide/animating/plus';
-import { impactFeedback } from '@tauri-apps/plugin-haptics';
+import { hapticImpact } from '@core/mobile/haptics';
import {
type Component,
createMemo,
@@ -47,7 +47,7 @@ function MobileDockButton(props: MobileDockButtonProps) {
type="button"
ref={props.ref}
onPointerDown={() => {
- impactFeedback('light');
+ hapticImpact('light');
setAnimating(true);
setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
props.onClick();
@@ -144,7 +144,7 @@ function FloatingCreateButton(props: {
type="button"
class="absolute bottom-full right-4 mb-14 w-11 h-11 rounded-full bg-panel text-accent flex items-center justify-center shadow-lg"
onPointerDown={() => {
- impactFeedback('light');
+ hapticImpact('light');
setAnimating(true);
setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
createAction()?.();
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
index 2de4cc0ce7..f78ea7f0d1 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
@@ -26,7 +26,7 @@ import {
} from 'solid-js';
import { DropdownMenu } from '@kobalte/core/dropdown-menu';
import ChevronDownIcon from '@icon/regular/caret-down.svg';
-import { impactFeedback } from '@tauri-apps/plugin-haptics';
+import { hapticImpact } from '@core/mobile/haptics';
import { cn } from '@ui/utils/classname';
type TabItem = SegmentedControlItem;
@@ -261,7 +261,7 @@ const MobileViewTabs = (props: { view: TabbedListView }) => {
}
const id = closest?.dataset.tabId;
if (id && scrollActiveId() !== id) {
- impactFeedback('light');
+ hapticImpact('light');
setScrollActiveId(id);
}
};
@@ -292,7 +292,7 @@ const MobileViewTabs = (props: { view: TabbedListView }) => {
const handleItemClick = (tabValue: string, idx: number) => {
const el = itemRefs[idx];
if (el) scrollRef.scrollTo({ left: el.offsetLeft, behavior: 'smooth' });
- impactFeedback('light');
+ hapticImpact('light');
applyTabPreset(props.view, tabValue);
};
diff --git a/js/app/packages/core/directive/touchHandler.ts b/js/app/packages/core/directive/touchHandler.ts
index b87a1bef31..1dab5df81b 100644
--- a/js/app/packages/core/directive/touchHandler.ts
+++ b/js/app/packages/core/directive/touchHandler.ts
@@ -1,7 +1,5 @@
-import { impactFeedback } from '@tauri-apps/plugin-haptics';
import { type Accessor, createSignal, type JSX, onCleanup } from 'solid-js';
-
-export const hasHaptics = false;
+import { hapticImpact } from '@core/mobile/haptics';
export interface TouchHandlerOptions {
onLongPress?: JSX.EventHandler<HTMLElement, TouchEvent>;
@@ -70,7 +68,7 @@ export function touchHandler(
timer = window.setTimeout(() => {
longPressTriggered = true;
setLongPressActivated(true);
- void impactFeedback('medium');
+ hapticImpact('medium');
props().onLongPress?.(
e as TouchEvent & { currentTarget: HTMLElement; target: Element }
);
diff --git a/js/app/packages/core/mobile/haptics.ts b/js/app/packages/core/mobile/haptics.ts
new file mode 100644
index 0000000000..df492b45b1
--- /dev/null
+++ b/js/app/packages/core/mobile/haptics.ts
@@ -0,0 +1,9 @@
+import { isTauri } from '@tauri-apps/api/core';
+import { impactFeedback } from '@tauri-apps/plugin-haptics';
+
+type ImpactStyle = Parameters<typeof impactFeedback>[0];
+
+export function hapticImpact(style: ImpactStyle): void {
+ if (!isTauri()) return;
+ void impactFeedback(style);
+}