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.

feat(soup-view): drag down to refresh on mobile (#4645)

Peter Chinman2b5497001b69
diff --git a/js/app/packages/app/component/EmailAuth.tsx b/js/app/packages/app/component/EmailAuth.tsx
index 5a8557eec3..b5b215c866 100644
--- a/js/app/packages/app/component/EmailAuth.tsx
+++ b/js/app/packages/app/component/EmailAuth.tsx
@@ -130,7 +130,7 @@ function EmailLinkCallback(props: Pick<EmailAuthParams, 'successPath'>) {
// callback so the inbox panel shows it immediately on return rather
// than flashing a stale list until its own refetch lands.
await query.refetch();
- toast.success('Inbox connected', { mobile: true });
+ toast.success('Inbox connected');
navigateToEmailSettings();
},
async (err) => {
@@ -149,7 +149,7 @@ function EmailLinkCallback(props: Pick<EmailAuthParams, 'successPath'>) {
});
return;
}
- toast.failure('Failed to add inbox', { mobile: true });
+ toast.failure('Failed to add inbox');
navigateToSuccess();
}
);
diff --git a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsx b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsx
index 2eb388bf50..1b8c5f2645 100644
--- a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsx
+++ b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingConnectAccounts.tsx
@@ -56,7 +56,7 @@ export function OnboardingConnectAccounts() {
if (githubLinked()) return;
if (DEBUG_FAKE_GITHUB) {
setDebugGithubConnected(true);
- toast.success('GitHub connected (debug)', { mobile: true });
+ toast.success('GitHub connected (debug)');
return;
}
const isIos = getNativeMobilePlatform() === 'ios';
@@ -88,16 +88,16 @@ export function OnboardingConnectAccounts() {
if (!auth.success) {
if (auth.error !== 'User canceled login') {
- toast.failure('Failed to connect GitHub', { mobile: true });
+ toast.failure('Failed to connect GitHub');
}
return;
}
await invalidateGithubLinkStatus();
- toast.success('GitHub connected', { mobile: true });
+ toast.success('GitHub connected');
} catch (error) {
console.error('connect github failed', error);
- toast.failure('Failed to connect GitHub', { mobile: true });
+ toast.failure('Failed to connect GitHub');
}
};
diff --git a/js/app/packages/app/component/mobile/PullToRefresh.tsx b/js/app/packages/app/component/mobile/PullToRefresh.tsx
new file mode 100644
index 0000000000..3ba4cc61ea
--- /dev/null
+++ b/js/app/packages/app/component/mobile/PullToRefresh.tsx
@@ -0,0 +1,253 @@
+import { toast } from '@core/component/Toast/Toast';
+import { hapticImpact } from '@core/mobile/haptics';
+import { isMobile } from '@core/mobile/isMobile';
+import Spinner from '@phosphor-icons/core/bold/spinner-bold.svg';
+import { cn } from '@ui';
+import {
+ type Accessor,
+ createEffect,
+ createMemo,
+ createSignal,
+ on,
+ onCleanup,
+ Show,
+} from 'solid-js';
+
+/** Movement (px) before a touch commits to a direction. Mirrors EntityRow. */
+const DIRECTIONALITY_THRESHOLD = 5;
+/** Finger-to-indicator damping while pulling. */
+const PULL_RESISTANCE = 0.5;
+/** Damped pull distance (px) past which releasing triggers a refresh. */
+const PULL_THRESHOLD = 60;
+/** Slope the overdrag damping settles at — deep overdrag keeps moving at
+ * this fraction of the base rate instead of hitting a hard stop. */
+const OVERDRAG_RESISTANCE = 0.25;
+/** Damped px over which the overdrag resistance fades in: the pull's slope
+ * eases from 1 down to OVERDRAG_RESISTANCE across roughly this distance,
+ * so crossing the threshold has no felt kink. */
+const OVERDRAG_FADE = 40;
+/** Retract transition length (ms). */
+const SETTLE_MS = 250;
+/** Spin floor so near-instant refreshes still read as a completed refresh. */
+const MIN_REFRESH_SPIN_MS = 200;
+/** Refreshes running longer than this are treated as failed. Bounds the
+ * spinner when connectivity is gone: refetches can pause or hang
+ * indefinitely rather than reject (navigator.onLine is unreliable in
+ * WKWebView, so the offline case can't be detected up front). */
+const REFRESH_TIMEOUT_MS = 8000;
+
+type PullPhase = 'idle' | 'pulling' | 'refreshing' | 'settling';
+
+type PullGesture = {
+ startX: number;
+ startY: number;
+ /** null until the gesture commits to a direction. */
+ pulling: boolean | null;
+};
+
+/**
+ * Pull-to-refresh for a touch scroll container: dragging down from the top
+ * reveals a floating spinner badge that arms past a threshold and, once
+ * released, spins until `onRefresh` settles. Renders nothing off mobile.
+ *
+ * Mount inside a `position: relative` wrapper of the scroll container. Pull translates the scroll container down, and the opaque rows sliding away
+ * are what reveal it. A transform leaves layout and scrollTop untouched,
+ * so the virtualizer's scroll math is unaffected.
+ */
+export function PullToRefresh(props: {
+ /** Element the gesture attaches to and that translates with the pull.
+ * Usually the scroll container, but a non-scrollable element (e.g. an
+ * empty state) works too — its scrollTop reads 0, so pulls always start
+ * from rest. */
+ scrollContainer: Accessor<HTMLElement | undefined>;
+ onRefresh: () => Promise<unknown>;
+}) {
+ const [phase, setPhase] = createSignal<PullPhase>('idle');
+ const [pull, setPull] = createSignal(0);
+
+ let gesture: PullGesture | null = null;
+ let settleTimer: number | undefined;
+ onCleanup(() => window.clearTimeout(settleTimer));
+
+ const retract = () => {
+ setPhase('settling');
+ setPull(0);
+ window.clearTimeout(settleTimer);
+ settleTimer = window.setTimeout(() => setPhase('idle'), SETTLE_MS);
+ };
+
+ const triggerRefresh = () => {
+ setPhase('refreshing');
+ setPull(PULL_THRESHOLD);
+
+ const minSpin = new Promise((resolve) =>
+ window.setTimeout(resolve, MIN_REFRESH_SPIN_MS)
+ );
+ const timeout = new Promise((_, reject) =>
+ window.setTimeout(
+ () => reject(new Error('Refresh timed out')),
+ REFRESH_TIMEOUT_MS
+ )
+ );
+ void Promise.allSettled([
+ Promise.race([props.onRefresh(), timeout]),
+ minSpin,
+ ]).then(([refreshResult]) => {
+ if (refreshResult.status === 'rejected') {
+ toast.failure('Failed to refresh');
+ }
+ retract();
+ });
+ };
+
+ const onTouchStart = (e: TouchEvent) => {
+ if (!isMobile() || phase() !== 'idle') return;
+ if (e.touches.length !== 1) return;
+
+ const container = props.scrollContainer();
+ if (!container || container.scrollTop > 0) return;
+
+ const touch = e.touches[0];
+ gesture = { startX: touch.clientX, startY: touch.clientY, pulling: null };
+ };
+
+ const onTouchMove = (e: TouchEvent) => {
+ if (!gesture) return;
+
+ if (e.touches.length !== 1) {
+ onTouchCancel();
+ return;
+ }
+
+ const touch = e.touches[0];
+ const dx = touch.clientX - gesture.startX;
+ const dy = touch.clientY - gesture.startY;
+
+ if (gesture.pulling === null) {
+ if (
+ Math.abs(dx) < DIRECTIONALITY_THRESHOLD &&
+ Math.abs(dy) < DIRECTIONALITY_THRESHOLD
+ )
+ return;
+
+ // Only a downward, predominantly vertical drag becomes a pull —
+ // anything else stays with native scrolling / the row swipe handlers.
+ gesture.pulling = dy > Math.abs(dx);
+ if (!gesture.pulling) {
+ gesture = null;
+ return;
+ }
+ setPhase('pulling');
+ }
+
+ // Own the gesture: the indicator tracks the finger instead of the list
+ // scrolling (the container is already at its top).
+ if (e.cancelable) e.preventDefault();
+
+ const base = Math.max(dy - DIRECTIONALITY_THRESHOLD, 0) * PULL_RESISTANCE;
+ // Exponential blend past the threshold: slope starts at 1 and eases
+ // toward OVERDRAG_RESISTANCE, so the extra resistance fades in instead
+ // of kicking in abruptly.
+ const over = Math.max(base - PULL_THRESHOLD, 0);
+ const damped =
+ Math.min(base, PULL_THRESHOLD) +
+ OVERDRAG_RESISTANCE * over +
+ (1 - OVERDRAG_RESISTANCE) *
+ OVERDRAG_FADE *
+ (1 - Math.exp(-over / OVERDRAG_FADE));
+ const wasArmed = pull() >= PULL_THRESHOLD;
+ setPull(damped);
+ if (damped >= PULL_THRESHOLD !== wasArmed) hapticImpact('light');
+ };
+
+ const onTouchEnd = () => {
+ if (!gesture) return;
+ const wasPulling = gesture.pulling === true;
+ gesture = null;
+ if (!wasPulling) return;
+
+ if (pull() >= PULL_THRESHOLD) triggerRefresh();
+ else retract();
+ };
+
+ const onTouchCancel = () => {
+ if (!gesture) return;
+ const wasPulling = gesture.pulling === true;
+ gesture = null;
+ if (wasPulling) retract();
+ };
+
+ // Dedupe by element identity: the accessor may re-evaluate for reactive
+ // reasons that leave the element unchanged (e.g. a fallback target derived
+ // from fetch state), and re-running the effect would reset the transform
+ // mid-refresh — a visible bounce.
+ const scrollContainer = createMemo(() => props.scrollContainer());
+
+ createEffect(
+ on(scrollContainer, (el) => {
+ if (!el) return;
+
+ el.addEventListener('touchstart', onTouchStart, { passive: true });
+ el.addEventListener('touchmove', onTouchMove, { passive: false });
+ el.addEventListener('touchend', onTouchEnd, { passive: true });
+ el.addEventListener('touchcancel', onTouchCancel, { passive: true });
+
+ // The list follows the finger: translate the scroll container by the
+ // damped pull, tracking directly while pulling and easing back
+ // otherwise (mirroring the badge's settle transition).
+ createEffect(() => {
+ el.style.transform = pull() > 0 ? `translateY(${pull()}px)` : '';
+ el.style.transition =
+ phase() === 'pulling' ? '' : `transform ${SETTLE_MS}ms ease-out`;
+ });
+
+ onCleanup(() => {
+ // The target can swap mid-gesture (empty state ↔ list when a refresh
+ // lands rows); the old element takes its listeners with it, so drop
+ // the gesture here or the phase wedges in 'pulling'.
+ onTouchCancel();
+ el.style.transform = '';
+ el.style.transition = '';
+ el.removeEventListener('touchstart', onTouchStart);
+ el.removeEventListener('touchmove', onTouchMove);
+ el.removeEventListener('touchend', onTouchEnd);
+ el.removeEventListener('touchcancel', onTouchCancel);
+ });
+ })
+ );
+
+ const progress = () => Math.min(pull() / PULL_THRESHOLD, 1);
+ const isRefreshing = () => phase() === 'refreshing';
+
+ return (
+ <Show when={isMobile()}>
+ <div
+ class="pointer-events-none absolute inset-x-0 flex justify-center"
+ style={{
+ top: 'var(--mobile-content-inset-top, 0px)',
+ }}
+ aria-hidden
+ >
+ <div
+ class="flex items-center justify-center rounded-full"
+ style={{
+ opacity: Math.min(progress() * 1.5, 1),
+ transition:
+ phase() === 'pulling'
+ ? undefined
+ : `opacity ${SETTLE_MS}ms ease-out`,
+ }}
+ >
+ <Spinner
+ class={cn('size-7', isRefreshing() && 'animate-spin')}
+ style={
+ isRefreshing()
+ ? undefined
+ : { transform: `rotate(${pull() * 3}deg)` }
+ }
+ />
+ </div>
+ </div>
+ </Show>
+ );
+}
diff --git a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
index 94f9a7e9bf..4ccfefb33b 100644
--- a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
@@ -154,6 +154,7 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {
],
duration: 3_000,
stack: true,
+ hideOnMobile: true,
});
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
index ed88371e04..f0bac4dfff 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
@@ -60,6 +60,7 @@ import {
import { useNotificationsForEntity } from '@notifications';
import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import { useQueryClient } from '@queries/client';
+import { invalidateUserNotifications } from '@queries/notification/user-notifications';
import type {
GroupMeta as ApiGroupMeta,
GroupByField,
@@ -100,6 +101,11 @@ type DataSource<T> = {
isFetchingNextPage: Accessor<boolean>;
hasNextPage: Accessor<boolean>;
fetchNextPage: VoidFunction;
+ /**
+ * Full refresh (e.g. mobile pull-to-refresh): invalidate every soup query
+ * plus notification state. Resolves once the active refetches settle.
+ */
+ refresh: () => Promise<void>;
};
type SoupViewInitializeOptions = {
@@ -234,7 +240,7 @@ export const SoupViewContextProvider: FlowComponent<
);
onCleanup(predicatesCaptorTeardown);
- const invalidateCache = () => {
+ const trimToFirstPage = () => {
const groupBy = serverGroupByField();
queryClient.setQueryData(
@@ -258,19 +264,19 @@ export const SoupViewContextProvider: FlowComponent<
const queryFilters: QueryStore = {
...store,
set: (query) => {
- invalidateCache();
+ trimToFirstPage();
store.set(query);
},
replace: (query) => {
- invalidateCache();
+ trimToFirstPage();
store.replace(query);
},
add: (query) => {
- invalidateCache();
+ trimToFirstPage();
store.add(query);
},
remove: (query) => {
- invalidateCache();
+ trimToFirstPage();
store.remove(query);
},
};
@@ -1002,6 +1008,21 @@ export const SoupViewContextProvider: FlowComponent<
searchQuery.fetchNextPage();
}
},
+ refresh: async () => {
+ if (!enabled()) return;
+
+ trimToFirstPage();
+
+ await Promise.all([
+ queryClient.invalidateQueries(
+ { queryKey: soupKeys._def },
+ // Reject on refetch failure so pull-to-refresh can surface it
+ // instead of retracting as if the refresh succeeded.
+ { throwOnError: true }
+ ),
+ invalidateUserNotifications(),
+ ]);
+ },
},
items,
rows,
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index b74756ca9c..6a4ae0567c 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -5,6 +5,7 @@ import {
} from '@app/component/GlobalAppState';
import { EntityRowProvider } from '@app/component/mobile/EntityRow';
import { FloatRegion } from '@app/component/mobile/float-regions/FloatRegion';
+import { PullToRefresh } from '@app/component/mobile/PullToRefresh';
import {
makeMarkDoneAction,
useEntityActionHotkeys,
@@ -1108,6 +1109,33 @@ export const SoupViewList = (props: SoupViewListProps) => {
HTMLDivElement | undefined
>();
+ // The virtualizer's scroll container, for mobile pull-to-refresh.
+ const [listScrollerRef, setListScrollerRef] = createSignal<
+ HTMLDivElement | undefined
+ >();
+
+ // The empty-state wrapper, so pull-to-refresh still works with no rows.
+ const [emptyStateRef, setEmptyStateRef] = createSignal<
+ HTMLDivElement | undefined
+ >();
+
+ // While a pull-driven refetch is in flight, the pull spinner is already
+ // the loading indicator — the loading/searching blocks stay unmounted so
+ // the empty state doesn't flash away (which would also unmount the
+ // gesture's target element mid-refresh).
+ const [isPullRefreshing, setIsPullRefreshing] = createSignal(false);
+
+ const pullRefresh = () => {
+ setIsPullRefreshing(true);
+ return source.refresh().finally(() => setIsPullRefreshing(false));
+ };
+
+ // Shared by the empty-state <Match> and the pull-to-refresh target so the
+ // gesture always attaches to whichever element is actually mounted.
+ const showEmptyState = () =>
+ ((!source.isFetching() || isPullRefreshing()) && !rows().length) ||
+ forceEmptyState();
+
const entityById = createMemo(
() => {
const list = rows() ?? [];
@@ -1265,9 +1293,23 @@ export const SoupViewList = (props: SoupViewListProps) => {
<Show when={isMobile() && source.isPlaceholderData()}>
<MobileTabLoadingBar />
</Show>
+ <Show when={isMobile()}>
+ <PullToRefresh
+ scrollContainer={() =>
+ showEmptyState() ? emptyStateRef() : listScrollerRef()
+ }
+ onRefresh={pullRefresh}
+ />
+ </Show>
<StaticMarkdownContext>
<Switch>
- <Match when={source.isFetching() && !rows().length}>
+ <Match
+ when={
+ source.isFetching() &&
+ !rows().length &&
+ !isPullRefreshing()
+ }
+ >
{/* Non-list states pad the chrome top themselves — the
panel leaves list views unpadded so rows can
under-scroll the status bar. */}
@@ -1278,7 +1320,8 @@ export const SoupViewList = (props: SoupViewListProps) => {
<Match
when={
(isSearchServiceLoading() || isLocalSearchSettling()) &&
- !rows().length
+ !rows().length &&
+ !isPullRefreshing()
}
>
<div class="flex items-center gap-2 p-3 text-xs text-text-muted mobile:mt-(--mobile-content-inset-top) mobile:mb-(--mobile-content-inset-bottom)">
@@ -1286,13 +1329,11 @@ export const SoupViewList = (props: SoupViewListProps) => {
Searching...
</div>
</Match>
- <Match
- when={
- (!source.isFetching() && !rows().length) ||
- forceEmptyState()
- }
- >
- <div class="flex-1 min-h-0 flex flex-col mobile:pt-(--mobile-content-inset-top) mobile:pb-(--mobile-content-inset-bottom)">
+ <Match when={showEmptyState()}>
+ <div
+ ref={setEmptyStateRef}
+ class="flex-1 min-h-0 flex flex-col mobile:pt-(--mobile-content-inset-top) mobile:pb-(--mobile-content-inset-bottom)"
+ >
<EmptyState
listView={currentView()}
search={!!searchText()}
@@ -1344,6 +1385,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
setLocalEntityListRef(el);
soupNavigationTouchHighlight(el);
}}
+ scrollerRef={setListScrollerRef}
virtualizerClass={'scrollbar-hidden space-y-2'}
class="overflow-hidden flex min-w-0"
virtualizerRef={registerVirtualizerHandler}
@@ -1670,6 +1712,8 @@ const DEFAULT_OVERSCAN = 5;
interface SoupListProps {
ref?: (el: HTMLDivElement) => void;
+ /** Receives the inner scroll container (the element that owns scrollTop). */
+ scrollerRef?: (el: HTMLDivElement) => void;
virtualizerRef?: (handle: VirtualizerHandle) => void;
class?: string;
virtualizerClass?: string;
@@ -1737,6 +1781,7 @@ const SoupList = (props: SoupListProps) => {
but still slide beneath it. `startMargin` keeps virtua's scroll
math correct for the leading spacer. */}
<div
+ ref={props.scrollerRef}
class={cn('overscroll-none', props.virtualizerClass)}
style={{
display: 'block',
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index b85bda788c..472624b37e 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -741,7 +741,6 @@ export function BaseInput(props: {
]
: undefined,
duration: 10_000,
- mobile: true,
});
pendingMentions.forEach((mention) => {
trackMention(blockId, 'document', mention.documentId);
diff --git a/js/app/packages/block-email/component/compose/Compose.tsx b/js/app/packages/block-email/component/compose/Compose.tsx
index 8744c65a4d..8cd3459c9e 100644
--- a/js/app/packages/block-email/component/compose/Compose.tsx
+++ b/js/app/packages/block-email/component/compose/Compose.tsx
@@ -425,7 +425,6 @@ export function EmailCompose(props: EmailComposeProps) {
]
: undefined,
duration: 8_000,
- mobile: true,
});
if (data.message.thread_db_id) {
replaceSplit({
diff --git a/js/app/packages/core/component/Toast/Toast.tsx b/js/app/packages/core/component/Toast/Toast.tsx
index 4621a26328..a0fa17b899 100644
--- a/js/app/packages/core/component/Toast/Toast.tsx
+++ b/js/app/packages/core/component/Toast/Toast.tsx
@@ -4,7 +4,7 @@ import CheckIcon from '@phosphor/check.svg';
import ExclamationIcon from '@phosphor/exclamation-mark.svg';
import Spinner from '@phosphor/spinner.svg';
import XIcon from '@phosphor/x.svg';
-import { Button, cn, Surface } from '@ui';
+import { Button, cn, Layer, Surface } from '@ui';
import type { Component, JSX } from 'solid-js';
import {
createEffect,
@@ -116,16 +116,13 @@ interface ToastAction {
/**
* Common options for all toast calls.
- *
- * Note: by default, toasts do NOT render on mobile. Pass `mobile: true` to opt
- * in to the mobile-styled toast region (centered above the mobile dock).
*/
interface ToastOptions {
subtext?: string;
/** Auto-dismiss duration in ms. When omitted, the toast uses a default 3s timer. */
duration?: number;
- /** When true, render this toast on mobile (in the mobile-specific region). */
- mobile?: boolean;
+ /** When true, don't render this toast on mobile. */
+ hideOnMobile?: boolean;
}
interface ToastSuccessOptions extends ToastOptions {
@@ -291,7 +288,11 @@ function ToastBodyWrapper(props: {
</Surface>
}
>
- {props.children}
+ <Layer depth={3}>
+ <div class="island relative w-[90vw] p-2 rounded-xl">
+ {props.children}
+ </div>
+ </Layer>
</Show>
);
}
@@ -457,22 +458,20 @@ function ToastContent(props: {
{(s) => (
<>
<div class="flex items-center gap-2 justify-between">
- <Show when={!props.mobile}>
- <div
- class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75"
- style={{ 'background-color': s().borderColor }}
- >
- <Dynamic
- component={s().icon}
- class={cn(
- 'size-3.5 text-surface',
- props.toastType === ToastType.LOADING
- ? 'animate-spin'
- : ''
- )}
- />
- </div>
- </Show>
+ <div
+ class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75"
+ style={{ 'background-color': s().borderColor }}
+ >
+ <Dynamic
+ component={s().icon}
+ class={cn(
+ 'size-3.5 text-surface',
+ props.toastType === ToastType.LOADING
+ ? 'animate-spin'
+ : ''
+ )}
+ />
+ </div>
<Toast.Title
class={cn(
'font-semibold grow shrink truncate text-left',
@@ -530,10 +529,13 @@ async function promise<T>(
error?: string | ((error: any) => string);
toastTypeDeterminer?: (result: T) => ToastType;
subtext?: string;
- mobile?: boolean;
+ /** When true, don't render the loading/result toasts on mobile. */
+ hideOnMobile?: boolean;
}
): Promise<T> {
- const useMobile = options.mobile && isMobile();
+ if (isMobile() && options.hideOnMobile) return promiseArg;
+
+ const useMobile = isMobile();
const region = useMobile ? 'mobile-toast-region' : 'toast-region';
const skipOpenAnimation = dismissActiveToast(region);
@@ -567,7 +569,9 @@ async function promise<T>(
const toastType =
options.toastTypeDeterminer?.(result) ?? ToastType.SUCCESS;
- createToast(successMessage, toastType, { mobile: options.mobile });
+ createToast(successMessage, toastType, {
+ hideOnMobile: options.hideOnMobile,
+ });
}
return result;
@@ -579,7 +583,7 @@ async function promise<T>(
typeof options.error === 'function'
? options.error(error)
: options.error;
- failure(errorMessage, { mobile: options.mobile });
+ failure(errorMessage, { hideOnMobile: options.hideOnMobile });
}
throw error;
});
@@ -592,10 +596,9 @@ function createToast(
toastType: ToastType,
options?: ToastSuccessOptions
) {
- const { subtext, actions, duration, stack, mobile } = options ?? {};
+ const { subtext, actions, duration, stack, hideOnMobile } = options ?? {};
- // On mobile, toasts only render when explicitly opted in via `mobile: true`.
- if (isMobile() && !mobile) return undefined;
+ if (isMobile() && hideOnMobile) return undefined;
if (!stack) {
const key = createToastKey(message, toastType);
@@ -605,7 +608,7 @@ function createToast(
}
}
- const useMobile = mobile && isMobile();
+ const useMobile = isMobile();
const region = useMobile ? 'mobile-toast-region' : 'toast-region';
const skipOpenAnimation = dismissActiveToast(region);
@@ -659,10 +662,9 @@ function embed(
persistent?: boolean;
duration?: number;
region?: string;
- mobile?: boolean;
}
) {
- const useMobile = options?.mobile && isMobile();
+ const useMobile = isMobile();
const region =
options?.region ?? (useMobile ? 'mobile-toast-region' : 'toast-region');
const skipOpenAnimation = dismissActiveToast(region);
@@ -697,11 +699,10 @@ function custom(
persistent?: boolean;
duration?: number;
region?: string;
- mobile?: boolean;
onDismiss?: () => void;
}
): number {
- const useMobile = options?.mobile && isMobile();
+ const useMobile = isMobile();
const region =
options?.region ?? (useMobile ? 'mobile-toast-region' : 'toast-region');
const skipOpenAnimation = dismissActiveToast(region);
diff --git a/js/app/packages/core/component/Toast/ToastRegion.tsx b/js/app/packages/core/component/Toast/ToastRegion.tsx
index 83ee0af38b..2af57df86d 100644
--- a/js/app/packages/core/component/Toast/ToastRegion.tsx
+++ b/js/app/packages/core/component/Toast/ToastRegion.tsx
@@ -23,9 +23,9 @@ export function ToastRegion() {
as a new one is shown, so no stacking is needed here.
*/}
<div
- class="fixed left-1/2 -translate-x-1/2 w-full max-w-[420px] px-4 pointer-events-none z-toast-region"
+ class="fixed left-1/2 -translate-x-1/2 w-full max-w-[420px] px-(--mobile-chrome-gutter) pointer-events-none z-toast-region"
style={{
- bottom: 'calc(var(--safe-bottom, 0px) + 104px)',
+ bottom: 'calc(var(--mobile-content-inset-bottom, 0px) + 12px)',
}}
>
<Toast.Region
diff --git a/js/app/packages/core/email-link/index.ts b/js/app/packages/core/email-link/index.ts
index c5e13f709d..07b64bc2d2 100644
--- a/js/app/packages/core/email-link/index.ts
+++ b/js/app/packages/core/email-link/index.ts
@@ -215,7 +215,7 @@ export function useAddInboxFlow() {
await initEmailLink({ linkId, forceShare }).match(
async () => {
await query.refetch();
- toast.success('Inbox connected', { mobile: true });
+ toast.success('Inbox connected');
},
async (error) => {
if (error.tag === 'AlreadyInitialized') {
@@ -230,7 +230,7 @@ export function useAddInboxFlow() {
});
return;
}
- toast.failure('Failed to add inbox', { mobile: true });
+ toast.failure('Failed to add inbox');
}
);
};
@@ -244,7 +244,7 @@ export function useAddInboxFlow() {
showPaywall(PaywallKey.MULTI_INBOX);
return;
}
- toast.failure('Failed to start Gmail link flow', { mobile: true });
+ toast.failure('Failed to start Gmail link flow');
return;
}
@@ -259,13 +259,13 @@ export function useAddInboxFlow() {
});
} catch (error) {
console.error('add-inbox authenticate failed', error);
- toast.failure('Failed to add inbox', { mobile: true });
+ toast.failure('Failed to add inbox');
return;
}
if (!auth.success || !auth.token) {
if (auth.error !== 'User canceled login') {
- toast.failure('Failed to add inbox', { mobile: true });
+ toast.failure('Failed to add inbox');
}
return;
}
diff --git a/js/app/packages/entity/src/extractors-notification/notification-actions.tsx b/js/app/packages/entity/src/extractors-notification/notification-actions.tsx
index 78b91a0d9b..120325b048 100644
--- a/js/app/packages/entity/src/extractors-notification/notification-actions.tsx
+++ b/js/app/packages/entity/src/extractors-notification/notification-actions.tsx
@@ -59,6 +59,7 @@ export function useNotificationStackActions(props: NotificationActionsProps) {
],
duration: 10_000,
stack: true,
+ hideOnMobile: true,
});
};