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(calendar): aim deep links at the event in the URL query (#5736)

gbirman02c218308c46
diff --git a/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx b/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
index 80813714af..6948dbf37f 100644
--- a/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
+++ b/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
@@ -3,6 +3,7 @@ import { useCalendarUiFlag } from '@app/features/calendar/hooks/use-calendar-ui-
import { isCalendarRangeSupported } from '@app/features/calendar/utils/calendar-supported-range';
import { useAnalytics } from '@app/lib/analytics/analytics-context';
import { usePosthog } from '@app/lib/analytics/posthog';
+import { globalSplitManager } from '@app/signal/splitLayout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { useUserId } from '@core/context/user';
@@ -10,6 +11,7 @@ import { createMethodRegistration } from '@core/orchestrator';
import { blockHandleSignal } from '@core/signal/load';
import { fetchCalendarMentionPreview } from '@queries/calendar/mention-preview';
import { useCalendarOccurrencesQuery } from '@queries/calendar/occurrences';
+import { useSearchParams } from '@solidjs/router';
import { createMemo, createSignal, onMount, Show } from 'solid-js';
import { CalendarFocusContextProvider } from './calendar-focus-target';
import {
@@ -105,11 +107,36 @@ function CalendarBlockAdapter(props: CalendarBlockProps) {
const userId = useUserId();
const analytics = useAnalytics();
const blockHandle = blockHandleSignal.get;
+ const [searchParams] = useSearchParams();
+ const searchParam = (value: string | string[] | undefined) =>
+ typeof value === 'string' && value.length > 0 ? value : undefined;
+ // In-app opens pass the target through split content props, but a deep
+ // link carries it in the query string, which never reaches block props.
+ // Query params are only trusted for a single-split URL, mirroring the
+ // channel block's deep-link guard.
+ const queryAim =
+ globalSplitManager()?.splits().length === 1
+ ? {
+ eventId: searchParam(searchParams.eventId),
+ occurrenceKey: searchParam(searchParams.occurrenceKey),
+ }
+ : {};
+ const initialAim: CalendarBlockProps = {
+ eventId:
+ typeof props.eventId === 'string' && props.eventId.length > 0
+ ? props.eventId
+ : queryAim.eventId,
+ occurrenceKey:
+ typeof props.occurrenceKey === 'string' && props.occurrenceKey.length > 0
+ ? props.occurrenceKey
+ : queryAim.occurrenceKey,
+ range: props.range,
+ };
let nextRequestId = 1;
let latestRequestId = 0;
const [targetRequest, setTargetRequest] = createSignal<
CalendarBlockTargetRequest | undefined
- >(targetRequestFromParams(props, nextRequestId++));
+ >(targetRequestFromParams(initialAim, nextRequestId++));
// Preview resolution is async, so a stale answer must never clobber a
// target the user has since re-aimed or cleared.
@@ -135,8 +162,12 @@ function CalendarBlockAdapter(props: CalendarBlockProps) {
setTargetRequest(undefined);
};
- if (!targetRequest() && typeof props.eventId === 'string' && props.eventId) {
- aimAtParams(props);
+ if (
+ !targetRequest() &&
+ typeof initialAim.eventId === 'string' &&
+ initialAim.eventId
+ ) {
+ aimAtParams(initialAim);
}
createMethodRegistration(blockHandle, {