/** * WordPress dependencies */ import apiFetch from '@safe-wordpress/api-fetch'; import { dispatch } from '@safe-wordpress/data'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { createErrorNotice } from '@neliosr/utils'; /** * Internal dependencies */ import { store as NSR_DATA } from '../../../store'; export async function setRecordingStatus( status: boolean ): Promise< void > { try { await dispatch( NSR_DATA ).lock(); await apiFetch( { path: '/neliosr/v1/recording-status', method: 'POST', data: { status }, } ); await dispatch( NSR_DATA ).receiveRecordingStatus( status ); await dispatch( NSR_DATA ).unlock(); } catch ( e ) { createErrorNotice( e, _x( 'Recordings status can’t be changed', 'text', 'nelio-session-recordings' ) ); await dispatch( NSR_DATA ).unlock(); } //end if } //end setRecordingStatus()