diff --git a/app/soapbox/features/feed-filtering/__tests__/feed-carousel.test.tsx b/app/soapbox/features/feed-filtering/__tests__/feed-carousel.test.tsx index f4c4690a9..dc34e73e0 100644 --- a/app/soapbox/features/feed-filtering/__tests__/feed-carousel.test.tsx +++ b/app/soapbox/features/feed-filtering/__tests__/feed-carousel.test.tsx @@ -21,7 +21,7 @@ jest.mock('../../../hooks/useDimensions', () => ({ describe('', () => { let store: any; - describe('with "feedUserFiltering" disabled', () => { + describe('with "carousel" disabled', () => { beforeEach(() => { store = { instance: { @@ -42,7 +42,7 @@ describe('', () => { }); }); - describe('with "feedUserFiltering" enabled', () => { + describe('with "carousel" enabled', () => { beforeEach(() => { store = { instance: { @@ -70,6 +70,8 @@ describe('', () => { mock.onGet('/api/v1/accounts/1/statuses').reply(200, [], { link: '; rel=\'prev\'', }); + + mock.onPost('/api/v1/truth/carousels/avatars/seen').reply(200); }); }); diff --git a/app/soapbox/features/feed-filtering/feed-carousel.tsx b/app/soapbox/features/feed-filtering/feed-carousel.tsx index b30ecba0a..481ae138e 100644 --- a/app/soapbox/features/feed-filtering/feed-carousel.tsx +++ b/app/soapbox/features/feed-filtering/feed-carousel.tsx @@ -96,7 +96,7 @@ const FeedCarousel = () => { if (avatars.length > 0) { setSeenAccountIds( avatars - .filter((avatar) => avatar.seen) + .filter((avatar) => avatar.seen !== false) .map((avatar) => avatar.account_id), ); } diff --git a/app/soapbox/pages/home-page.tsx b/app/soapbox/pages/home-page.tsx index 94dbc83b7..c65d9b86c 100644 --- a/app/soapbox/pages/home-page.tsx +++ b/app/soapbox/pages/home-page.tsx @@ -59,7 +59,7 @@ const HomePage: React.FC = ({ children }) => { )} - {features.feedUserFiltering && } + {features.carousel && } {children} diff --git a/app/soapbox/queries/carousels.ts b/app/soapbox/queries/carousels.ts index c908b352a..d6e05798a 100644 --- a/app/soapbox/queries/carousels.ts +++ b/app/soapbox/queries/carousels.ts @@ -1,12 +1,12 @@ import { useMutation, useQuery } from '@tanstack/react-query'; -import { useApi } from 'soapbox/hooks'; +import { useApi, useFeatures } from 'soapbox/hooks'; export type Avatar = { account_id: string account_avatar: string acct: string - seen: boolean + seen?: boolean } const CarouselKeys = { @@ -36,10 +36,15 @@ function useCarouselAvatars() { function useMarkAsSeen() { const api = useApi(); + const features = useFeatures(); - return useMutation((account_id: string) => api.post('/api/v1/truth/carousels/avatars/seen', { - account_id, - })); + return useMutation(async (accountId: string) => { + if (features.carouselSeen) { + await void api.post('/api/v1/truth/carousels/avatars/seen', { + account_id: accountId, + }); + } + }); } export { useCarouselAvatars, useMarkAsSeen }; \ No newline at end of file diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index f57458f98..1927bde2e 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -205,6 +205,19 @@ const getInstanceFeatures = (instance: Instance) => { v.software === PLEROMA, ]), + /** + * Whether to show the Feed Carousel for suggested Statuses. + * @see GET /api/v1/truth/carousels/avatars + * @see GET /api/v1/truth/carousels/suggestions + */ + carousel: v.software === TRUTHSOCIAL, + + /** + * Ability to mark a carousel avatar as "seen." + * @see POST /api/v1/truth/carousels/avatars/seen + */ + carouselSeen: v.software === TRUTHSOCIAL, + /** * Ability to accept a chat. * POST /api/v1/pleroma/chats/:id/accept @@ -371,9 +384,6 @@ const getInstanceFeatures = (instance: Instance) => { /** Whether the instance federates. */ federating: federation.get('enabled', true) === true, // Assume true unless explicitly false - /** Whether or not to show the Feed Carousel for suggested Statuses */ - feedUserFiltering: v.software === TRUTHSOCIAL, - /** * Can edit and manage timeline filters (aka "muted words"). * @see {@link https://docs.joinmastodon.org/methods/accounts/filters/}