/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
client/state/comments/utils.js
25 строк
791 B
flootr
chore: migrate `client/state/account-recovery` to `import/order` (#55439)
19 авг 2021, 11:05
Не верифицирован
19 авг 2021, 11:05
8cd4c3e
Код
Авторство
О чём код?
import { domForHtml } from 'calypso/lib/post-normalizer/utils'; export const getStateKey = ( siteId, postId ) => `${ siteId }-${ postId }`; export const deconstructStateKey = ( key ) => { const [ siteId, postId ] = key.split( '-' ); return { siteId: +siteId, postId: +postId }; }; export const getErrorKey = ( siteId, commentId ) => `${ siteId }-${ commentId }`; export const commentHasLink = ( commentContent, apiSuppliedValue ) => { // In case API provides value for has_link, skip parsing and return it instead. if ( typeof apiSuppliedValue !== 'undefined' ) { return apiSuppliedValue; } try { return !! domForHtml( commentContent ).getElementsByTagName( 'a' ).length; } catch ( e ) { return false; } }; export const getCommentDate = ( { date } ) => new Date( date );