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: do not scroll channel reply open (#711)

gbirmanb230a4c0f8e2
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsx
index 47744d5aec..d892246f41 100644
--- a/js/app/packages/app/component/UnifiedListView.tsx
+++ b/js/app/packages/app/component/UnifiedListView.tsx
@@ -296,9 +296,9 @@ export function UnifiedListView(props: UnifiedListViewProps) {
if (dontFocus()) return;
- const focusElement = localEntityListRef!.querySelector(
+ const focusElement = localEntityListRef?.querySelector(
`[data-entity-id="${entityId}"]`
- ) as HTMLElement;
+ );
if (focusElement instanceof HTMLElement) {
focusElement.focus({ preventScroll: true });
diff --git a/js/app/packages/block-channel/component/Message/MessageContainer.tsx b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
index bc39cc7eff..936d2ef686 100644
--- a/js/app/packages/block-channel/component/Message/MessageContainer.tsx
+++ b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
@@ -156,9 +156,8 @@ export function MessageContainer(props: MessageProps) {
// Scroll message to have editing input visible
createEffect(() => {
- if (editing() && props.virtualHandle) {
- const handle = props.virtualHandle!;
-
+ const handle = props.virtualHandle;
+ if (editing() && handle) {
requestAnimationFrame(() => {
const messageBounds = messageContainerRef.getBoundingClientRect();
const containerBounds = props.container?.getBoundingClientRect();
@@ -193,8 +192,11 @@ export function MessageContainer(props: MessageProps) {
: undefined;
});
- const previousNonThreadMessage = () =>
- props.listContext?.previousNonThreadedMessage;
+ const newDayPreviousNonThreadMessage = createMemo(() => {
+ const prev = props.listContext?.previousNonThreadedMessage;
+ if (!prev) return false;
+ return !isSameDay(new Date(message.created_at), new Date(prev.created_at));
+ });
// We consider a message consecutive if it's from the same user and the same day and has the same thread id.
const isConsecutive = createMemo(() => {
@@ -481,36 +483,11 @@ export function MessageContainer(props: MessageProps) {
props.setThreadViewStore(message.thread_id, () => ({
threadExpanded: true,
}));
-
- scrollIntoViewAndFocus({
- virtualHandle: props.virtualHandle,
- container: props.container,
- targetIndex: props.index() + 1,
- targetId:
- props.threadSiblings?.at(COLLAPSED_THREAD_INDEX_CUTOFF + 1)?.id ?? '',
- });
} else {
props.setThreadViewStore(message.thread_id, (prev) => ({
...prev,
threadExpanded: !prev.threadExpanded,
}));
- if (props.threadViewStore[message.thread_id]?.threadExpanded) {
- scrollIntoViewAndFocus({
- virtualHandle: props.virtualHandle,
- container: props.container,
- targetIndex: props.index() + 1,
- targetId: message.thread_id,
- });
- } else {
- scrollIntoViewAndFocus({
- virtualHandle: props.virtualHandle,
- container: props.container,
- targetIndex: props
- .orderedMessages()
- .findIndex((m) => m.id === message.thread_id),
- targetId: message.thread_id,
- });
- }
}
};
@@ -532,11 +509,7 @@ export function MessageContainer(props: MessageProps) {
(props.index() === 0 ||
(props.index() > 0 &&
!message.thread_id &&
- previousNonThreadMessage() &&
- !isSameDay(
- new Date(message.created_at),
- new Date(previousNonThreadMessage()!.created_at)
- )))
+ newDayPreviousNonThreadMessage()))
}
>
<MessageFlag text={formatRelativeDate(message.created_at)} />
@@ -688,8 +661,8 @@ export function MessageContainer(props: MessageProps) {
users={threadReplyUsers()}
onClick={handleThreadToggle}
isThreadOpen={
- props.threadViewStore[message.thread_id!]
- ?.threadExpanded
+ !!message.thread_id &&
+ props.threadViewStore[message.thread_id]?.threadExpanded
}
/>
</div>
@@ -761,7 +734,7 @@ export function MessageContainer(props: MessageProps) {
</ContextMenu.Item>
</Show>
<Show when={!reactionSearchOpen()}>
- <div class={MENU_CONTENT_CLASS + ' mt-4'}>
+ <div class={`${MENU_CONTENT_CLASS} mt-4`}>
<For each={actions().filter((a) => a.enabled)}>
{(a) => (
<>
diff --git a/js/app/packages/block-channel/component/MessageList/MessageList.tsx b/js/app/packages/block-channel/component/MessageList/MessageList.tsx
index 8e77a3d65b..9b0e6369cc 100644
--- a/js/app/packages/block-channel/component/MessageList/MessageList.tsx
+++ b/js/app/packages/block-channel/component/MessageList/MessageList.tsx
@@ -131,11 +131,14 @@ export function MessageList(props: MessageListProps) {
});
const checkIfNewMessage = (message: Message) => {
+ const lastViewed_ = lastViewed();
+ const openedChannel_ = openedChannel();
return (
- !!lastViewed() &&
- new Date(message.created_at) > new Date(lastViewed()!) &&
+ !!lastViewed_ &&
+ !!openedChannel_ &&
+ new Date(message.created_at) > new Date(lastViewed_) &&
userId() !== message.sender_id &&
- new Date(message.created_at) < new Date(openedChannel()!)
+ new Date(message.created_at) < new Date(openedChannel_)
);
};
@@ -706,39 +709,44 @@ export function MessageList(props: MessageListProps) {
return (
<Show
when={
- isParentless() ||
- isThreadExpanded() ||
- isThreadIndexWithinCutoff()
+ (isParentless() ||
+ isThreadExpanded() ||
+ isThreadIndexWithinCutoff()) &&
+ virtualHandle()
}
>
- <MessageContainer
- message={row.message}
- lastViewed={lastViewed}
- newMessageIndex={newMessageIndex}
- isFocused={isFocused(row.id)}
- setFocusedMessageId={props.setFocusedMessageId}
- index={i}
- orderedMessages={props.orderedMessages}
- threadSiblings={viewThreads[
- row.message.thread_id ?? ''
- ]?.filter(messageFilterFn)}
- threadChildren={viewThreads[row.message.id ?? '']?.filter(
- messageFilterFn
- )}
- threadViewStore={threadViewStore}
- setThreadViewStore={setThreadViewStore}
- threadInputAttachmentsStore={threadInputAttachmentsStore}
- setThreadInputAttachmentsStore={
- setThreadInputAttachmentsStore
- }
- newIndicatorShown={newIndicatorShown}
- setNewIndicatorShown={setNewIndicatorShown}
- virtualHandle={virtualHandle()!}
- container={containerRef()}
- listContext={messageListContext[row.id]}
- setLastMessageRef={props.setLastMessageRef}
- isTarget={isActiveTargetMessage(row.message.id)}
- />
+ {(handle) => (
+ <MessageContainer
+ message={row.message}
+ lastViewed={lastViewed}
+ newMessageIndex={newMessageIndex}
+ isFocused={isFocused(row.id)}
+ setFocusedMessageId={props.setFocusedMessageId}
+ index={i}
+ orderedMessages={props.orderedMessages}
+ threadSiblings={viewThreads[
+ row.message.thread_id ?? ''
+ ]?.filter(messageFilterFn)}
+ threadChildren={viewThreads[
+ row.message.id ?? ''
+ ]?.filter(messageFilterFn)}
+ threadViewStore={threadViewStore}
+ setThreadViewStore={setThreadViewStore}
+ threadInputAttachmentsStore={
+ threadInputAttachmentsStore
+ }
+ setThreadInputAttachmentsStore={
+ setThreadInputAttachmentsStore
+ }
+ newIndicatorShown={newIndicatorShown}
+ setNewIndicatorShown={setNewIndicatorShown}
+ virtualHandle={handle()}
+ container={containerRef()}
+ listContext={messageListContext[row.id]}
+ setLastMessageRef={props.setLastMessageRef}
+ isTarget={isActiveTargetMessage(row.message.id)}
+ />
+ )}
</Show>
);
}}