Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.2 KB
Raw Blame
import type { GalleryBoard, GalleryView } from '@features/gallery/core/types';

import { getBoardCounts } from './galleryStateView';

export const getGalleryCountForView = (board: GalleryBoard, galleryView: GalleryView): number => {
  const counts = getBoardCounts(board);

  return galleryView === 'assets' ? counts.uploads : counts.media;
};

type Translate = (key: string, options?: Record<string, unknown>) => string;

/**
 * Whose board someone else's board is and what the caller may do with it, for its row: "{owner} · Can view". Nothing
 * for the caller's own boards. A board the server reports no access for keeps its owner's name alone.
 */
export const getGalleryBoardOwnerLabel = (board: GalleryBoard, t: Translate): string | null => {
  const { access } = board;
  if (access === undefined) {
    return board.ownerName ?? null;
  }
  if (access.role === 'owner') {
    return null;
  }
  const owner = board.ownerName ?? t('widgets.gallery.boardAccess.deletedOwner');
  const level =
    access.adminOverride || access.role === null
      ? t('widgets.gallery.boardAccess.admin')
      : t(`widgets.gallery.boardAccess.${access.role}`);
  return t('widgets.gallery.boardAccess.ownerAndAccess', { access: level, owner });
};