Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Peepr timeline id format #1718

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/utils/timeline_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const exactly = string => `^${string}$`;
const anyBlog = '[a-z0-9-]{1,32}';
const uuidV4 = '[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}';

const peeprPostsTimelineId = ({ blog, postId, maybeOriginal, maybeTop, search, postType, tag }) =>
`peepr-posts-${blog}-${postId}-${maybeOriginal}-${maybeTop}-${search}-${postType}-${tag}`;

export const followingTimelineFilter = ({ dataset: { timeline, timelineId } }) =>
timeline === '/v2/timeline/dashboard' ||
timelineId === '/dashboard/following' ||
Expand All @@ -20,15 +23,15 @@ export const followingTimelineSelector = createSelector(
// includes "channel" user blog view page
export const anyBlogTimelineFilter = ({ dataset: { timeline, timelineId } }) =>
timeline?.match(exactly(`/v2/blog/${anyBlog}/posts`)) ||
timelineId?.match(exactly(`peepr-posts-${anyBlog}-undefined-undefined-undefined-undefined-undefined-undefined`)) ||
timelineId?.match(exactly(peeprPostsTimelineId({ blog: anyBlog }))) ||
timelineId?.match(exactly(`blog-view-${anyBlog}`)) ||
timelineId?.match(exactly(`blog-${uuidV4}-${anyBlog}`));

// includes "channel" user blog view page
export const blogTimelineFilter = blog =>
({ dataset: { timeline, timelineId } }) =>
timeline === `/v2/blog/${blog}/posts` ||
timelineId === `peepr-posts-${blog}-undefined-undefined-undefined-undefined-undefined-undefined` ||
timelineId === peeprPostsTimelineId({ blog }) ||
timelineId === `blog-view-${blog}` ||
timelineId?.match(exactly(`blog-${uuidV4}-${blog}`));

Expand Down