Carousel: make seen
optional, only hit the API if features.carouselSeen is supported
This commit is contained in:
parent
30abdab924
commit
8f3c0a1071
2 changed files with 16 additions and 5 deletions
|
@ -1,12 +1,12 @@
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { useApi } from 'soapbox/hooks';
|
import { useApi, useFeatures } from 'soapbox/hooks';
|
||||||
|
|
||||||
export type Avatar = {
|
export type Avatar = {
|
||||||
account_id: string
|
account_id: string
|
||||||
account_avatar: string
|
account_avatar: string
|
||||||
acct: string
|
acct: string
|
||||||
seen: boolean
|
seen?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const CarouselKeys = {
|
const CarouselKeys = {
|
||||||
|
@ -36,10 +36,15 @@ function useCarouselAvatars() {
|
||||||
|
|
||||||
function useMarkAsSeen() {
|
function useMarkAsSeen() {
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
const features = useFeatures();
|
||||||
|
|
||||||
return useMutation((account_id: string) => api.post('/api/v1/truth/carousels/avatars/seen', {
|
return useMutation(async (accountId: string) => {
|
||||||
account_id,
|
if (features.carouselSeen) {
|
||||||
}));
|
await void api.post('/api/v1/truth/carousels/avatars/seen', {
|
||||||
|
account_id: accountId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { useCarouselAvatars, useMarkAsSeen };
|
export { useCarouselAvatars, useMarkAsSeen };
|
|
@ -212,6 +212,12 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
*/
|
*/
|
||||||
carousel: v.software === TRUTHSOCIAL,
|
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.
|
* Ability to accept a chat.
|
||||||
* POST /api/v1/pleroma/chats/:id/accept
|
* POST /api/v1/pleroma/chats/:id/accept
|
||||||
|
|
Loading…
Reference in a new issue