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(new-channels): add back live indicators (#2315)

teo9504d1300951
diff --git a/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx b/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx
index 541f4a8e34..d2a3a0292f 100644
--- a/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx
+++ b/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx
@@ -2,6 +2,7 @@ import {
Channel as NewChannel,
type ChannelHandle,
} from '@channel/Channel/Channel';
+import { ChannelTopBarLiveIndicators } from '@channel/Channel/ChannelTopBarLiveIndicators';
import { useBlockId } from '@core/block';
import { EntityPermissionsGate } from '@core/component/EntityPermissionsGate';
import { createSignal, Match, Suspense, Switch } from 'solid-js';
@@ -38,15 +39,18 @@ function NewTop(props: {
return (
<Suspense>
- <ChannelTopLeft
- channelId={props.channelId}
- channelType={channelType()!}
- participants={participants() ?? []}
- channelName={channelName() ?? 'New Channel'}
- tabs={tabs()}
- activeTab={props.activeTab}
- onTabChange={props.onTabChange}
- />
+ <>
+ <ChannelTopLeft
+ channelId={props.channelId}
+ channelType={channelType()!}
+ participants={participants() ?? []}
+ channelName={channelName() ?? 'New Channel'}
+ tabs={tabs()}
+ activeTab={props.activeTab}
+ onTabChange={props.onTabChange}
+ />
+ <ChannelTopBarLiveIndicators />
+ </>
</Suspense>
);
}
diff --git a/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx b/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx
new file mode 100644
index 0000000000..39b4b2963e
--- /dev/null
+++ b/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx
@@ -0,0 +1,41 @@
+import { SplitHeaderRight } from '@app/component/split-layout/components/SplitHeader';
+import { useBlockId } from '@core/block';
+import { BlockLiveIndicators } from '@core/component/LiveIndicators';
+import { isTabFocused } from '@core/signal/tabFocus';
+import { connectionGatewayClient } from '@service-connection/client';
+import { onCleanup, onMount } from 'solid-js';
+
+const PING_INTERVAL = 20_000;
+
+export function ChannelTopBarLiveIndicators() {
+ const channelId = useBlockId();
+ let pingInterval: ReturnType<typeof setInterval> | undefined;
+
+ const trackChannel = (action: 'open' | 'close' | 'ping') => {
+ connectionGatewayClient.trackEntity({
+ entity_type: 'channel',
+ entity_id: channelId,
+ action,
+ });
+ };
+
+ onMount(() => {
+ trackChannel('open');
+ pingInterval = setInterval(() => {
+ if (isTabFocused()) {
+ trackChannel('ping');
+ }
+ }, PING_INTERVAL);
+ });
+
+ onCleanup(() => {
+ trackChannel('close');
+ if (pingInterval) clearInterval(pingInterval);
+ });
+
+ return (
+ <SplitHeaderRight>
+ <BlockLiveIndicators />
+ </SplitHeaderRight>
+ );
+}