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.

621 B
Raw Blame
import type { PropertyOption } from '@service-properties/generated/schemas/propertyOption';

const EMPTY_OPTIONS: PropertyOption[] = [];

/**
 * Keeps the last successful option catalog usable when a background refresh
 * fails offline. Query errors describe freshness, not invalid cached data.
 */
export function usablePropertyOptions(
  query: {
    data: PropertyOption[] | undefined;
    isError: boolean;
    isPlaceholderData?: boolean;
  },
  fallback: PropertyOption[] = EMPTY_OPTIONS
): PropertyOption[] {
  return query.isPlaceholderData && !query.isError
    ? fallback
    : (query.data ?? EMPTY_OPTIONS);
}