Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(channels): remove dependency on block signals in channel (#1418)
teo40f67b3ef332
diff --git a/js/app/packages/block-channel/component/BaseInput.tsx b/js/app/packages/block-channel/component/BaseInput.tsxindex fb71140f44..e31c7d13e2 100644--- a/js/app/packages/block-channel/component/BaseInput.tsx+++ b/js/app/packages/block-channel/component/BaseInput.tsx@@ -1,7 +1,3 @@-import {- isDraggingOverChannelSignal,- isValidChannelDragSignal,-} from '@block-channel/signal/attachment';import { handleFileUpload } from '@block-channel/utils/inputAttachments';import {$convertSingleMentionToCard,@@ -13,7 +9,6 @@ import {replaceCheckboxesWithMentions,} from '@block-channel/utils/taskModeConversion';import { useTaskMode } from '@block-channel/hooks/taskmode';-import { isInBlock } from '@core/block';import { LabelAndHotKey } from '@core/component/Tooltip';import { FileDropOverlay } from '@core/component/FileDropOverlay';import {@@ -117,6 +112,10 @@ type BaseInputProps = {closeDraft?: () => void;/** whether this input is for a reply (affects styling) */isReplyInput?: boolean;+ /** whether a file is being dragged over the parent channel container */+ isDraggingOverChannel?: Accessor<boolean>;+ /** whether the dragged file is a valid channel attachment */+ isValidChannelDrag?: Accessor<boolean>;};/** the time after a user stops typing before we consider them idle. we want smooth remote changes, but local changes should happen more immediately. */@@ -129,13 +128,8 @@ export function BaseInput(props: BaseInputProps) {const key = props.inputAttachments.key;const [showFormatRibbon, setShowFormatRibbon] = createSignal(false);const [isDraggedOver, setIsDraggedOver] = createSignal(false);- const [isValidChannelDrag] = isInBlock()- ? isValidChannelDragSignal- : createSignal(false);-- const [isDraggingOverChannel, setIsDraggingOverChannel] = isInBlock()- ? isDraggingOverChannelSignal- : createSignal(false);+ const isDraggingOverChannel = props.isDraggingOverChannel ?? (() => false);+ const isValidChannelDrag = props.isValidChannelDrag ?? (() => true);const attachments = () => props.inputAttachments.store[key] ?? [];@@ -460,7 +454,6 @@ export function BaseInput(props: BaseInputProps) {ref={containerRef}use:fileFolderDrop={{onDrop: (files, folders) => {- setIsDraggingOverChannel(false);handleFileFolderDrop(files, folders, (uploadEntries) =>handleFileUpload(uploadEntries, {store: props.inputAttachments.store,diff --git a/js/app/packages/block-channel/component/Channel.tsx b/js/app/packages/block-channel/component/Channel.tsxindex f527b00aef..a4f1f36775 100644--- a/js/app/packages/block-channel/component/Channel.tsx+++ b/js/app/packages/block-channel/component/Channel.tsx@@ -1,11 +1,6 @@import { useGlobalNotificationSource } from '@app/component/GlobalAppState';import { useNavigatedFromJK } from '@app/component/useNavigatedFromJK';import { URL_PARAMS } from '@block-channel/constants';-import {- isDraggingOverChannelSignal,- isValidChannelDragSignal,-} from '@block-channel/signal/attachment';-import { activeThreadIdSignal } from '@block-channel/signal/threads';import { handleFileUpload } from '@block-channel/utils/inputAttachments';import { withAnalytics } from '@coparse/analytics';import { TrackingEvents } from '@coparse/analytics/src/types/TrackingEvents';@@ -85,8 +80,6 @@ export function Channel(props: {channelId: string;target?: TargetMessageInfo;}) {- const [_activeThreadId, setActiveThreadId] = activeThreadIdSignal;-const channelContext = useChannelContext();const channelQuery = useChannelQuery(() => props.channelId);const latestActivity = useChannelActivity(props.channelId);@@ -118,8 +111,8 @@ export function Channel(props: {const [orderedMessages, setOrderedMessages] = createSignal<Message[]>([]);const scopeId = blockHotkeyScopeSignal.get;const blockRef = blockElementSignal.get;- const setIsDraggingOverChannel = isDraggingOverChannelSignal.set;- const setIsValidChannelDrag = isValidChannelDragSignal.set;+ const [isDraggingOverChannel, setIsDraggingOverChannel] = createSignal(false);+ const [isValidChannelDrag, setIsValidChannelDrag] = createSignal(true);const notificationSource = useGlobalNotificationSource();const blockHandle = blockHandleSignal.get;@@ -148,9 +141,6 @@ export function Channel(props: {goToLocationFromParams: async (params: Record<string, unknown>) => {const threadId = params[URL_PARAMS.thread] as string | undefined;const messageId = params[URL_PARAMS.message] as string | undefined;- if (threadId) {- setActiveThreadId(threadId);- }if (messageId) {setTargetMessage({messageId,@@ -456,6 +446,8 @@ export function Channel(props: {onFocusLeaveStart={onChannelInputFocusLeaveStart}autoFocusOnMount={autoFocusOnMount()}domRef={setChannelInputRef}+ isDraggingOverChannel={isDraggingOverChannel}+ isValidChannelDrag={isValidChannelDrag}/></Suspense></div>diff --git a/js/app/packages/block-channel/component/ChannelInput.tsx b/js/app/packages/block-channel/component/ChannelInput.tsxindex 8e006de4d1..2885eb0262 100644--- a/js/app/packages/block-channel/component/ChannelInput.tsx+++ b/js/app/packages/block-channel/component/ChannelInput.tsx@@ -11,7 +11,7 @@ import type { IUser } from '@core/user';import { channelParticipantInfo } from '@core/user/util';import { usePostTypingUpdateMutation } from '@queries/channel/typing';import type { ChannelParticipant } from '@service-comms/generated/models/channelParticipant';-import { createMemo, createSignal, onMount } from 'solid-js';+import { type Accessor, createMemo, createSignal, onMount } from 'solid-js';import type { SetStoreFunction } from 'solid-js/store';import { BaseInput } from './BaseInput';import { useSendChannelMessage } from '@block-channel/hooks/message';@@ -26,6 +26,8 @@ export type ChannelInputProps = {onFocusLeaveStart?: (e: KeyboardEvent) => void;autoFocusOnMount?: boolean;domRef?: (ref: HTMLDivElement) => void | HTMLDivElement;+ isDraggingOverChannel?: Accessor<boolean>;+ isValidChannelDrag?: Accessor<boolean>;};export function ChannelInput(props: ChannelInputProps) {@@ -83,6 +85,8 @@ export function ChannelInput(props: ChannelInputProps) {channelUsers={channelUsers}autoFocusOnMount={props.autoFocusOnMount}domRef={props.domRef}+ isDraggingOverChannel={props.isDraggingOverChannel}+ isValidChannelDrag={props.isValidChannelDrag}/>);}diff --git a/js/app/packages/block-channel/component/Compose.tsx b/js/app/packages/block-channel/component/Compose.tsxindex 2be0212108..7ab18d1db2 100644--- a/js/app/packages/block-channel/component/Compose.tsx+++ b/js/app/packages/block-channel/component/Compose.tsx@@ -4,7 +4,6 @@ import {StaticSplitLabel,} from '@app/component/split-layout/components/SplitLabel';import { SplitToolbarLeft } from '@app/component/split-layout/components/SplitToolbar';-import { isInBlock } from '@core/block';import { FileDropOverlay } from '@core/component/FileDropOverlay';import { RecipientSelector } from '@core/component/RecipientSelector';import { fileFolderDrop } from '@core/directive/fileFolderDrop';@@ -18,10 +17,6 @@ import {import { handleFileFolderDrop } from '@core/util/upload';import { createEffect, createMemo, createSignal, on, Show } from 'solid-js';import { createStore } from 'solid-js/store';-import {- isDraggingOverChannelSignal,- isValidChannelDragSignal,-} from '../signal/attachment';import { handleFileUpload } from '../utils/inputAttachments';import { DraftChannelInput } from './ChannelInput';@@ -31,12 +26,6 @@ export function ChannelCompose() {const [channelName, setChannelName] = createSignal<string>('');const [isDraggedOver, setIsDraggedOver] = createSignal(false);- const [isValidChannelDrag] = isInBlock()- ? isValidChannelDragSignal- : createSignal(true);- const [isDraggingOverChannel, setIsDraggingOverChannel] = isInBlock()- ? isDraggingOverChannelSignal- : createSignal(false);const [channelInputAttachmentsStore, setChannelInputAttachmentsStore] =createStore<Record<string, InputAttachment[]>>({});@@ -117,7 +106,6 @@ export function ChannelCompose() {class="relative flex flex-col w-full h-full panel"use:fileFolderDrop={{onDrop: (files, folders) => {- setIsDraggingOverChannel(false);handleFileFolderDrop(files, folders, (uploadEntries) =>handleFileUpload(uploadEntries, {store: channelInputAttachmentsStore,@@ -134,13 +122,8 @@ export function ChannelCompose() {},}}>- <Show when={isDraggedOver() || isDraggingOverChannel()}>- <FileDropOverlay valid={isValidChannelDrag()}>- <Show when={!isValidChannelDrag()}>- <div class="font-mono text-failure">- [!] Invalid attachment file- </div>- </Show>+ <Show when={isDraggedOver()}>+ <FileDropOverlay valid={true}><div class="font-mono">Drop any file here to add it to the conversation</div>diff --git a/js/app/packages/block-channel/signal/attachment.ts b/js/app/packages/block-channel/signal/attachment.tsdeleted file mode 100644index b53f0e7b27..0000000000--- a/js/app/packages/block-channel/signal/attachment.ts+++ /dev/null@@ -1,3 +0,0 @@-import { createBlockSignal } from '@core/block';-export const isDraggingOverChannelSignal = createBlockSignal(false);-export const isValidChannelDragSignal = createBlockSignal(true);diff --git a/js/app/packages/block-channel/signal/channelBlockData.ts b/js/app/packages/block-channel/signal/channelBlockData.tsdeleted file mode 100644index 1aad83adfe..0000000000--- a/js/app/packages/block-channel/signal/channelBlockData.ts+++ /dev/null@@ -1,3 +0,0 @@-import { blockDataSignalAs } from '@core/block';-import type { ChannelData } from '../definition';-export const channelBlockDataSignal = blockDataSignalAs<ChannelData>('channel');diff --git a/js/app/packages/block-channel/signal/threads.ts b/js/app/packages/block-channel/signal/threads.tsindex 02c2492c52..8e7ee67c33 100644--- a/js/app/packages/block-channel/signal/threads.ts+++ b/js/app/packages/block-channel/signal/threads.ts@@ -1,25 +1,5 @@-import { createBlockSignal } from '@core/block';import type { Message } from '@service-comms/generated/models/message';-import { useSearchParams } from '@solidjs/router';export type MessageWithThreadId = Message & {thread_id: NonNullable<Message['thread_id']>;};--/** stores the id of the thread currently being viewed */-export const activeThreadIdSignal = createBlockSignal<string>();--/** Toggle the active thread by id- * if the thread is already active, it will be closed */-export function toggleThread(threadId?: string) {- const [, setSearchParams] = useSearchParams();- const [activeThreadId, setActiveThreadId] = activeThreadIdSignal;-- if (activeThreadId() === threadId) {- setActiveThreadId(undefined);- setSearchParams({ thread_id: undefined });- } else {- setActiveThreadId(threadId);- setSearchParams({ thread_id: threadId });- }-}