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(channel): bad block name param in channel attachments (#645)

Seamusc2d0a5951980
diff --git a/js/app/packages/block-channel/component/AttachmentsModal.tsx b/js/app/packages/block-channel/component/AttachmentsModal.tsx
index b47c0c0260..5b015e213e 100644
--- a/js/app/packages/block-channel/component/AttachmentsModal.tsx
+++ b/js/app/packages/block-channel/component/AttachmentsModal.tsx
@@ -3,11 +3,12 @@ import { useDrawerControl } from '@app/component/split-layout/components/SplitDr
import { messageAttachmentsStore } from '@block-channel/signal/attachment';
import { channelStore } from '@block-channel/signal/channel';
import { threadsStore } from '@block-channel/signal/threads';
-import { type BlockName, useBlockId } from '@core/block';
+import { type BlockAlias, type BlockName, useBlockId } from '@core/block';
import { InlineItemPreview } from '@core/component/ItemPreview';
import { toast } from '@core/component/Toast/Toast';
import { Tooltip } from '@core/component/Tooltip';
import { UserIcon } from '@core/component/UserIcon';
+import { fileTypeToBlockName } from '@core/constant/allBlocks';
import {
isAccessiblePreviewItem,
isDocumentPreviewItem,
@@ -135,7 +136,7 @@ function makeAttachmentFromMention(
type AttachmentItemProps = {
attachment: Attachment;
- onNavigate: (blockName: BlockName, blockId: string) => void;
+ onNavigate: (blockName: BlockName | BlockAlias, blockId: string) => void;
};
function AttachmentItem(props: AttachmentItemProps) {
@@ -160,7 +161,7 @@ function AttachmentItem(props: AttachmentItemProps) {
const handleClick = () => {
const item = preview();
if (isAccessiblePreviewItem(item) && isDocumentPreviewItem(item)) {
- props.onNavigate(item.fileType as BlockName, item.id);
+ props.onNavigate(fileTypeToBlockName(item.fileType), item.id);
} else {
toast.failure('Failed to open attachment');
}
diff --git a/js/app/packages/core/component/References.tsx b/js/app/packages/core/component/References.tsx
index 4e3aabc9ae..e50a346015 100644
--- a/js/app/packages/core/component/References.tsx
+++ b/js/app/packages/core/component/References.tsx
@@ -1,6 +1,6 @@
import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';
import { useSplitLayout } from '@app/component/split-layout/layout';
-import type { BlockName } from '@core/block';
+import type { BlockAlias, BlockName } from '@core/block';
import { toast } from '@core/component/Toast/Toast';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import {
@@ -93,7 +93,10 @@ export function References(props: ReferenceProps) {
messageLocation(channelId, messageId, threadId);
};
- const navigateToItem = (blockName: BlockName, blockId: string) => {
+ const navigateToItem = (
+ blockName: BlockName | BlockAlias,
+ blockId: string
+ ) => {
replaceOrInsertSplit({
type: blockName,
id: blockId,
@@ -103,7 +106,7 @@ export function References(props: ReferenceProps) {
const navigateToGenericReference = (item: PreviewItem) => {
if (isAccessiblePreviewItem(item) && isDocumentPreviewItem(item)) {
const blockId = item.id;
- const blockType = fileTypeToBlockName(item.fileType) as BlockName;
+ const blockType = fileTypeToBlockName(item.fileType);
navigateToItem(blockType, blockId);
} else {
toast.failure('Failed to open reference');