/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
client/reader/post-key.js
64 строки
1 KB
Gabriel Caires
Reader: migrate QueryReaderPost fetch to React Query (READ-383) (#110339)
30 апр 2026, 16:30
Не верифицирован
30 апр 2026, 16:30
5842d7f
Код
Авторство
О чём код?
export function keyForPost( post ) { if ( ! post ) { return; } if ( post.feed_ID && post.feed_item_ID ) { return { feedId: post.feed_ID, postId: post.feed_item_ID, }; } if ( post.is_external ) { return { feedId: post.feed_ID || post.site_ID, postId: post.feed_item_ID || post.ID, }; } return { blogId: post.site_ID, postId: post.ID, }; } export function keysAreEqual( a, b ) { if ( a === b ) { return true; } if ( ( ! a && b ) || ( a && ! b ) || ( ! a && ! b && a !== b ) ) { return false; } if ( ( a.isGap && ! b.isGap ) || ( ! a.isGap && b.isGap ) ) { return false; } if ( a.isGap && b.isGap ) { return a.from === b.from && a.to === b.to; } if ( a.postId !== b.postId ) { return false; } if ( a.feedId ) { return a.feedId === b.feedId; } return a.blogId === b.blogId; } export function keyToString( postKey ) { if ( ! postKey || postKey.isGap ) { return null; } if ( postKey.isRecommendationBlock ) { return `rec-${ postKey.index }`; } else if ( postKey.isPromptBlock ) { return `prompt-${ postKey.index }`; } else if ( postKey.feedId ) { return `feed-${ postKey.postId }-${ postKey.feedId }`; } else if ( postKey.blogId ) { return `blog-${ postKey.postId }-${ postKey.blogId }`; } return null; // should never happen! } export { isPostKeyLike } from '@automattic/api-core';