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): retsore (accidentally) deleted channel image attachments [bbb896f (#1461)

Seamusb2902a71987d
diff --git a/js/app/packages/block-channel/component/Attachment.tsx b/js/app/packages/block-channel/component/Attachment.tsx
index 4b9782cbd8..0e040a6db7 100644
--- a/js/app/packages/block-channel/component/Attachment.tsx
+++ b/js/app/packages/block-channel/component/Attachment.tsx
@@ -1,13 +1,17 @@
+import { ImagePreview } from '@core/component/ImagePreview';
import { ItemPreview } from '@core/component/ItemPreview';
+import { VideoPreview } from '@core/component/VideoPreview';
import {
type InputAttachment,
isStaticAttachmentType,
+ STATIC_IMAGE,
+ STATIC_VIDEO,
} from '@core/store/cacheChannelInput';
import { matches } from '@core/util/match';
import Close from '@phosphor-icons/core/regular/x.svg?component-solid';
import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';
import { blockNameToItemType } from '@service-storage/client';
-import { Match, Show, Switch } from 'solid-js';
+import { createSignal, Match, Show, Switch } from 'solid-js';
type AttachmentProps = {
attachment: InputAttachment;
@@ -16,8 +20,56 @@ type AttachmentProps = {
};
export function Attachment(props: AttachmentProps) {
+ const [hover, setHover] = createSignal(false);
+
+ const isStaticMedia = () =>
+ props.attachment.blockName === STATIC_IMAGE ||
+ props.attachment.blockName === STATIC_VIDEO;
+
return (
<Switch>
+ <Match when={isStaticMedia()}>
+ <div
+ class="relative"
+ onMouseEnter={() => setHover(true)}
+ onMouseLeave={() => setHover(false)}
+ >
+ <Show when={hover() && props.remove}>
+ <Close
+ width={24}
+ height={24}
+ class="text-ink absolute -top-2 -right-2 rounded-full bg-menu p-1 border border-edge-muted z-[10] cursor-pointer"
+ onClick={() => props.remove?.(props.attachment)}
+ />
+ </Show>
+ <Show when={props.attachment.pending}>
+ <div class="flex flex-col items-center justify-center gap-2 w-[60px] h-[60px] border border-edge-muted rounded-md bg-menu">
+ <Spinner class="w-4 h-4 animate-spin" />
+ </div>
+ </Show>
+ <Show
+ when={
+ !props.attachment.pending &&
+ props.attachment.blockName === STATIC_IMAGE
+ }
+ >
+ <ImagePreview
+ image={{
+ id: props.attachment.id,
+ }}
+ variant="small"
+ />
+ </Show>
+ <Show
+ when={
+ !props.attachment.pending &&
+ props.attachment.blockName === STATIC_VIDEO
+ }
+ >
+ <VideoPreview id={props.attachment.id} variant="small" />
+ </Show>
+ </div>
+ </Match>
<Match
when={matches(
props.attachment.blockName,