From e8870e9de52effc09dea3378756fc4e822623bd8 Mon Sep 17 00:00:00 2001 From: Yoginth Date: Tue, 19 Nov 2024 03:39:21 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=B0=20Rename=20publication=20to=20post?= =?UTF-8?q?=20for=20v3=20preparation=20(#v3-pub-to-posts)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../api/src/routes/lists/{publications.ts => posts.ts} | 0 .../lists/{publications.spec.ts => posts.spec.ts} | 10 +++++----- apps/web/src/components/List/ListFeed.tsx | 2 +- apps/web/src/components/Staff/Stats/LensStats.tsx | 4 ++-- apps/web/src/components/StaffTools/Panels/Post.tsx | 2 +- apps/web/src/helpers/pushToImpressions.ts | 8 ++++---- .../src/store/non-persisted/post/usePostAudioStore.ts | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) rename apps/api/src/routes/lists/{publications.ts => posts.ts} (100%) rename apps/api/tests/lists/{publications.spec.ts => posts.spec.ts} (80%) diff --git a/apps/api/src/routes/lists/publications.ts b/apps/api/src/routes/lists/posts.ts similarity index 100% rename from apps/api/src/routes/lists/publications.ts rename to apps/api/src/routes/lists/posts.ts diff --git a/apps/api/tests/lists/publications.spec.ts b/apps/api/tests/lists/posts.spec.ts similarity index 80% rename from apps/api/tests/lists/publications.spec.ts rename to apps/api/tests/lists/posts.spec.ts index d0d6714c1f62..4c29d44183cf 100644 --- a/apps/api/tests/lists/publications.spec.ts +++ b/apps/api/tests/lists/posts.spec.ts @@ -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) { @@ -15,7 +15,7 @@ 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" } }); @@ -23,8 +23,8 @@ describe("GET /lists/publications", () => { 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 } }); diff --git a/apps/web/src/components/List/ListFeed.tsx b/apps/web/src/components/List/ListFeed.tsx index d5f099a6d00b..a7f7dc465d4a 100644 --- a/apps/web/src/components/List/ListFeed.tsx +++ b/apps/web/src/components/List/ListFeed.tsx @@ -36,7 +36,7 @@ const ListFeed: FC = ({ list, showHeader = false }) => { const getListPosts = async (id: string): Promise => { try { - const { data } = await axios.get(`${HEY_API_URL}/lists/publications`, { + const { data } = await axios.get(`${HEY_API_URL}/lists/posts`, { params: { id } }); diff --git a/apps/web/src/components/Staff/Stats/LensStats.tsx b/apps/web/src/components/Staff/Stats/LensStats.tsx index b3fdba8aae33..3e684a489ada 100644 --- a/apps/web/src/components/Staff/Stats/LensStats.tsx +++ b/apps/web/src/components/Staff/Stats/LensStats.tsx @@ -69,7 +69,7 @@ const LensStats: FC = () => { name="Authentications" /> - + { name="WTF Dismissed" /> - + = ({ post }) => {
} - title="Publication ID" + title="Post ID" value={post?.id} > {post?.id} diff --git a/apps/web/src/helpers/pushToImpressions.ts b/apps/web/src/helpers/pushToImpressions.ts index 8fa3e0adefc1..6382c9ac4ed4 100644 --- a/apps/web/src/helpers/pushToImpressions.ts +++ b/apps/web/src/helpers/pushToImpressions.ts @@ -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; } diff --git a/apps/web/src/store/non-persisted/post/usePostAudioStore.ts b/apps/web/src/store/non-persisted/post/usePostAudioStore.ts index 87824679869a..17d4ba137d8c 100644 --- a/apps/web/src/store/non-persisted/post/usePostAudioStore.ts +++ b/apps/web/src/store/non-persisted/post/usePostAudioStore.ts @@ -1,14 +1,14 @@ 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: "", @@ -16,8 +16,8 @@ export const DEFAULT_AUDIO_POST: AudioPublication = { }; interface State { - audioPost: AudioPublication; - setAudioPost: (audioPost: AudioPublication) => void; + audioPost: AudioPost; + setAudioPost: (audioPost: AudioPost) => void; } const store = create((set) => ({