pl-hooks: Work on making this an actual library
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
export * from './contexts/api-client';
|
||||
export * from './contexts/query-client';
|
||||
|
||||
export * from './hooks/accounts/useAccount';
|
||||
export * from './hooks/accounts/useAccountRelationship';
|
||||
export * from './hooks/markers/useMarkers';
|
||||
export * from './hooks/markers/useUpdateMarkerMutation';
|
||||
export * from './hooks/notifications/useNotification';
|
||||
export * from './hooks/notifications/useNotificationList';
|
||||
export * from './hooks/statuses/useStatus';
|
||||
|
||||
export * from './importer';
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
/**
|
||||
* Status normalizer:
|
||||
* Converts API statuses into our internal format.
|
||||
* @see {@link https://docs.joinmastodon.org/entities/status/}
|
||||
*/
|
||||
import { type Account as BaseAccount, type Status as BaseStatus, type MediaAttachment, mentionSchema } from 'pl-api';
|
||||
import * as v from 'valibot';
|
||||
|
||||
type StatusApprovalStatus = Exclude<BaseStatus['approval_status'], null>;
|
||||
type StatusVisibility = 'public' | 'unlisted' | 'private' | 'direct' | 'group' | 'mutuals_only' | 'local';
|
||||
@ -23,7 +19,7 @@ const normalizeStatus = ({ account, accounts, reblog, poll, group, quote, ...sta
|
||||
const hasSelfMention = status.mentions.some(mention => account.id === mention.id);
|
||||
|
||||
if (isSelfReply && !hasSelfMention) {
|
||||
const selfMention = mentionSchema.parse(account);
|
||||
const selfMention = v.parse(mentionSchema, account);
|
||||
mentions = [selfMention, ...mentions];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user