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.

709 B
Raw Blame
import type { CacheHost } from '@graphql-cache/host/types';
import { type Accessor, createSignal } from 'solid-js';

/** Async project creation must not publish into a replacement viewer or cache. */
export function captureProjectCacheScope(
  userId: Accessor<string | undefined>,
  cacheHost: () => CacheHost | undefined
) {
  const viewer = userId();
  const host = cacheHost();
  const [valid, setValid] = createSignal(true);
  const unsubscribe = host?.onCacheGenerationChanged((change) => {
    if (change.storage === 'reset') setValid(false);
  });
  return {
    viewer,
    host,
    isCurrent: () => valid() && viewer === userId() && host === cacheHost(),
    dispose: () => unsubscribe?.(),
  };
}