/** * External dependencies */ import { last } from 'lodash'; import type { Maybe, Uuid } from '@nelio-content/types'; /** * Internal dependencies */ import type { State } from '../../types'; export function getActiveSocialProfile( state: State ): Maybe< Uuid > { const activeNetwork = state.status.activeSocialNetwork; const allProfiles = state.attributes.profileIds.all; const fallback = allProfiles.length ? undefined : state.attributes.profileIds.fallback; const networkProfiles = state.attributes.profileIds.byNetwork[ activeNetwork ]; return last( networkProfiles ) ?? fallback?.value; } export function isPreviewVisible( state: State ): boolean { return !! state.status.isPreviewVisible; }