Skip to content

Commit

Permalink
📰 Rename publication to post for v3 preparation (#v3-pub-to-posts)
Browse files Browse the repository at this point in the history
Summary: Renamed "publication" to "post" and added a new API endpoint for fetching posts.

Highlights:

• Introduced `get` function in `posts.ts` to fetch posts with pagination.
• Updated tests in `posts.spec.ts` to validate new API endpoint.
• Changed variable names and labels from "publication" to "post" across components.

Read more: https://pierre.co/hey/hey/v3-pub-to-posts
  • Loading branch information
Yoginth authored and Pierre committed Nov 19, 2024
1 parent 14a829f commit e8870e9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { TEST_URL } from "tests/helpers/constants";
import getTestAuthHeaders from "tests/helpers/getTestAuthHeaders";
import { describe, expect, test } from "vitest";

describe("GET /lists/publications", () => {
describe("GET /lists/posts", () => {
test("should return 400 if no id is provided", async () => {
try {
await axios.get(`${TEST_URL}/lists/publications`, {
await axios.get(`${TEST_URL}/lists/posts`, {
headers: getTestAuthHeaders()
});
} catch (error: any) {
Expand All @@ -15,16 +15,16 @@ describe("GET /lists/publications", () => {
});

test("should return 200 with a list's profile's publications", async () => {
const { data, status } = await axios.get(`${TEST_URL}/lists/publications`, {
const { data, status } = await axios.get(`${TEST_URL}/lists/posts`, {
params: { id: "0c34a529-8db6-40b8-9b35-7f474f7d509a" }
});

expect(status).toBe(200);
expect(data.result).toHaveLength(50);
});

test("should return 200 with a list's profile's publications with pagination", async () => {
const { data, status } = await axios.get(`${TEST_URL}/lists/publications`, {
test("should return 200 with a list's profile's posts with pagination", async () => {
const { data, status } = await axios.get(`${TEST_URL}/lists/posts`, {
params: { id: "0c34a529-8db6-40b8-9b35-7f474f7d509a", page: 2 }
});

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/List/ListFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ListFeed: FC<ListFeedProps> = ({ list, showHeader = false }) => {

const getListPosts = async (id: string): Promise<string[]> => {
try {
const { data } = await axios.get(`${HEY_API_URL}/lists/publications`, {
const { data } = await axios.get(`${HEY_API_URL}/lists/posts`, {
params: { id }
});

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Staff/Stats/LensStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const LensStats: FC = () => {
name="Authentications"
/>
<NumberedStat count={data.relay_usage_count} name="Relay Usage" />
<NumberedStat count={data.posts_count} name="Publications" />
<NumberedStat count={data.posts_count} name="Posts" />
<NumberedStat count={data.profiles_count} name="Profiles" />
<NumberedStat
count={data.quality_profiles_count}
Expand All @@ -85,7 +85,7 @@ const LensStats: FC = () => {
name="WTF Dismissed"
/>
<NumberedStat count={data.notifications_count} name="Notifications" />
<NumberedStat count={data.momoka_count} name="Momoka Publications" />
<NumberedStat count={data.momoka_count} name="Momoka Posts" />
<NumberedStat
count={data.media_snapshots_count}
name="Media Snapshots"
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/StaffTools/Panels/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const PostStaffTool: FC<PostStaffToolProps> = ({ post }) => {
<div className="mt-3 space-y-2">
<MetaDetails
icon={<HashtagIcon className="ld-text-gray-500 size-4" />}
title="Publication ID"
title="Post ID"
value={post?.id}
>
{post?.id}
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/helpers/pushToImpressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { IS_MAINNET } from "@hey/data/constants";
import getCurrentSession from "./getCurrentSession";

/**
* Push publication to impressions queue
* @param id Publication ID
* Push post to impressions queue
* @param id Post ID
* @returns void
*/
const pushToImpressions = (id: string): void => {
const { id: sessionProfileId } = getCurrentSession();

// Don't push impressions for the current user
const publicationProfileId = id.split("-")[0];
if (publicationProfileId === sessionProfileId) {
const postProfileId = id.split("-")[0];
if (postProfileId === sessionProfileId) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/store/non-persisted/post/usePostAudioStore.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { createTrackedSelector } from "react-tracked";
import { create } from "zustand";

interface AudioPublication {
interface AudioPost {
artist: string;
cover: string;
mimeType: string;
title: string;
}

export const DEFAULT_AUDIO_POST: AudioPublication = {
export const DEFAULT_AUDIO_POST: AudioPost = {
artist: "",
cover: "",
mimeType: "",
title: ""
};

interface State {
audioPost: AudioPublication;
setAudioPost: (audioPost: AudioPublication) => void;
audioPost: AudioPost;
setAudioPost: (audioPost: AudioPost) => void;
}

const store = create<State>((set) => ({
Expand Down

1 comment on commit e8870e9

@vercel
Copy link

@vercel vercel bot commented on e8870e9 Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./

hey.xyz
web-heyxyz.vercel.app
web-git-main-heyxyz.vercel.app
heyxyz.vercel.app

Please sign in to comment.